fix single line comment behavior on insert, remove unnecessary commented blocks

This commit is contained in:
Andrés González 2022-05-03 22:11:28 -04:00
parent 384d89ba7a
commit 9b49c5db0d

View File

@ -56,20 +56,19 @@ define-command -hidden javascript-indent-on-char %<
define-command -hidden javascript-insert-on-new-line %< define-command -hidden javascript-insert-on-new-line %<
evaluate-commands -draft -itersel %< evaluate-commands -draft -itersel %<
execute-keys <semicolon> execute-keys <semicolon>
# NOT working, copies single line comment "//" try %[
# try %[ evaluate-commands -draft -save-regs '/"' %[
# evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix
# # copy the commenting prefix execute-keys -save-regs '' k <a-x>1s^\h*(//+\h*)<ret> y
# execute-keys -save-regs '' k <a-x>1s^\h*(//+\h*)<ret> y try %[
# try %[ # if the previous comment isn't empty, create a new one
# # if the previous comment isn't empty, create a new one execute-keys <a-x><a-K>^\h*//+\h*$<ret> j<a-x>s^\h*<ret>P
# execute-keys <a-x><a-K>^\h*//+\h*$<ret> j<a-x>s^\h*<ret>P ] catch %[
# ] catch %[ # if there is no text in the previous comment, remove it completely
# # if there is no text in the previous comment, remove it completely execute-keys d
# execute-keys d ]
# ] ]
# ] ]
# ]
try %[ try %[
# if the previous line isn't within a comment scope, break # if the previous line isn't within a comment scope, break
execute-keys -draft k<a-x> <a-k>^(\h*/\*|\h+\*(?!/))<ret> execute-keys -draft k<a-x> <a-k>^(\h*/\*|\h+\*(?!/))<ret>
@ -102,8 +101,6 @@ define-command -hidden javascript-insert-on-new-line %<
# align the new star with the previous one # align the new star with the previous one
execute-keys K<a-x>1s^[^*]*(\*)<ret>& execute-keys K<a-x>1s^[^*]*(\*)<ret>&
] ]
# # copy // comments prefix and following white spaces
# try %{ execute-keys -draft k <a-x> s ^\h*\K/{2,}\h* <ret> y gh j P }
> >
> >
@ -153,14 +150,6 @@ define-command -hidden javascript-indent-on-new-line %<
# Now indent and align that new line with the opening parenthesis/brace # Now indent and align that new line with the opening parenthesis/brace
execute-keys 1<a-&> & execute-keys 1<a-&> &
> > > >
# # preserve previous line indent
# try %{ execute-keys -draft <semicolon> K <a-&> }
# # filter previous line
# try %{ execute-keys -draft k : javascript-trim-indent <ret> }
# # indent after lines beginning / ending with opener token
# try %_ execute-keys -draft k <a-x> s [[({] <ret> <space> <a-l> <a-K> [\])}] <ret> j <a-gt> _
# # deindent closing token(s) when after cursor
# try %_ execute-keys -draft <a-x> <a-k> ^\h*[})\]] <ret> gh / [})\]] <ret> m <a-S> 1<a-&> _
> >
> >