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].
However, the proper fix was not included, in fact, the javascript files
have not been updated since 2017.
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.
[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 | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
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..8aa5ff3d2 100644
--- a/runtime/indent/javascript.vim
+++ b/runtime/indent/javascript.vim
@@ -473,7 +473,11 @@ function GetJavascriptIndent()
elseif num
return s:Nat(num_ind + get(l:,'case_offset',s:sw()) + l:switch_offset +
b_l + is_op)
endif
- return b_l + is_op
+ let ret = b_l + is_op
+ if !ret && exists('b:hi_indent.blocklnr')
+ return indent(b:hi_indent.blocklnr) + s:sw()
+ endif
+ return ret
endfunction
let &cpo = s:cpo_save
--
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/20220726191954.182036-1-felipe.contreras%40gmail.com.