In issue #3205 a monkey patch was mentioned, but it wasn't the proper
fix, the proper fix is in GetJavascriptIndent(), which was done in
2018 [1].
The monkey patch screwed all indentation inside blocks, like:
<script>
function test() {
let v1;
}
test();
</script>
We need to remove the monkey patch, and include the correct fix. I've
agregated a few fixes from Chris Paul and this is the resulting patch.
[1] https://github.com/pangloss/vim-javascript/commit/e110653
Cc: Chris Paul <[email protected]>
Signed-off-by: Felipe Contreras <[email protected]>
---
runtime/indent/html.vim | 2 +-
runtime/indent/javascript.vim | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim
index a3c32d634..65e0ffc40 100644
--- a/runtime/indent/html.vim
+++ b/runtime/indent/html.vim
@@ -600,7 +600,7 @@ func s:Alien3()
endif
if b:hi_indent.scripttype == "javascript"
" indent for further lines
- return eval(b:hi_js1indent) + GetJavascriptIndent()
+ return GetJavascriptIndent()
else
return -1
endif
diff --git a/runtime/indent/javascript.vim b/runtime/indent/javascript.vim
index f3bf96aa9..92c370824 100644
--- a/runtime/indent/javascript.vim
+++ b/runtime/indent/javascript.vim
@@ -473,6 +473,10 @@ function GetJavascriptIndent()
elseif num
return s:Nat(num_ind + get(l:,'case_offset',s:sw()) + l:switch_offset +
b_l + is_op)
endif
+ let nest = get(get(b:,'hi_indent',{}),'blocklnr')
+ if nest
+ return indent(nextnonblank(nest+1)) + b_l + is_op
+ endif
return b_l + is_op
endfunction
--
2.37.1.225.gfa48d685d2
--
--
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 on the web visit
https://groups.google.com/d/msgid/vim_dev/20220726211410.195383-1-felipe.contreras%40gmail.com.