@@ -68,25 +68,25 @@ function E.insert_eol(ctype, cfg)
6868
6969 -- We need RHS of cstr, if we are doing block comments or if RHS exists
7070 -- because even in line comment RHS do exists for some filetypes like jsx_element, ocaml
71- local if_rcs = ( ctype == U . ctype . block or rcs ) and padding .. rcs or ' '
71+ local if_rcs = rcs and padding .. rcs or ' '
7272
7373 local ecol
74- if line : match ( ' ^$ ' ) then
74+ if U . is_empty ( line ) then
7575 -- If line is empty, start comment at the correct indentation level
76- A .nvim_buf_set_lines (0 , srow - 1 , srow , false , { lcs .. padding .. if_rcs })
77- vim . cmd (' normal! ==' )
78- ecol = A .nvim_get_current_line (): len () - if_rcs : len () - 1
76+ A .nvim_buf_set_lines (0 , srow - 1 , srow , false , { lcs .. padding .. if_rcs })
77+ A . nvim_command (' normal! ==' )
78+ ecol = # A .nvim_get_current_line () - # if_rcs - 1
7979 else
8080 -- NOTE:
8181 -- 1. Python is the only language that recommends 2 spaces between the statement and the comment
8282 -- 2. Other than that, I am assuming that the users wants a space b/w the end of line and start of the comment
8383 local space = vim .bo .filetype == ' python' and ' ' or ' '
8484 local ll = line .. space .. lcs .. padding
8585
86- local erow = srow - 1
8786 ecol = # ll - 1
88- A .nvim_buf_set_lines (0 , erow , srow , false , { ll .. if_rcs })
87+ A .nvim_buf_set_lines (0 , srow - 1 , srow , false , { ll .. if_rcs })
8988 end
89+
9090 U .move_n_insert (srow , ecol )
9191 U .is_fn (cfg .post_hook , ctx )
9292end
0 commit comments