runtime(astro): catch json_decode() error when parsing tsconfig.json
Commit:
https://github.com/vim/vim/commit/a07a2f4c332bcf0f7fabf9be002027acf12c6801
Author: Christian Brabandt <[email protected]>
Date: Fri Aug 29 18:01:08 2025 +0200
runtime(astro): catch json_decode() error when parsing tsconfig.json
(which is jsonc filetype and there can contain comments)
fixes: #18141
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/ftplugin/astro.vim b/runtime/ftplugin/astro.vim
index 5d35ba962..856b96f23 100644
--- a/runtime/ftplugin/astro.vim
+++ b/runtime/ftplugin/astro.vim
@@ -3,6 +3,7 @@
" Maintainer: Romain Lafourcade <[email protected]>
" Last Change: 2024 Apr 21
" 2024 May 24 by Riley Bruins <[email protected]>
('commentstring')
+" 2025 Aug 29 by Vim project, add try/catch around
json_decode(), #18141
if exists("b:did_ftplugin")
finish
@@ -52,13 +53,17 @@ function! s:CollectPathsFromConfig() abort
endif
endif
- let paths_from_config = config_json
+ try
+ let paths_from_config = config_json
\ ->readfile()
\ ->filter({ _, val -> val =~ '^\s*[\[\]{}"0-9]' })
\ ->join()
\ ->json_decode()
\ ->get('compilerOptions', {})
\ ->get('paths', {})
+ catch /^Vim\%(( \+)\)\=:E491:/ " invalid json
+ let paths_from_config = {}
+ endtry
if !empty(paths_from_config)
let b:astro_paths = paths_from_config
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1us1kn-009Vks-2A%40256bit.org.