Skip to content

Commit

Permalink
Stop empty lines setting indentation to zero (#32)
Browse files Browse the repository at this point in the history
* Added check for empty lines when deciding indent level

* Fixed end

* Try with '' line check

* changed check for l:match("^%s*$")

* fixed regex check

* line -> v

* changed goto -> if ... then block

Co-authored-by: Paegodu <pablo@desktop.localdomain>
  • Loading branch information
paegodu and Paegodu authored Mar 15, 2022
1 parent f670649 commit f3b39e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/nvim_comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ function M.comment_toggle(line_start, line_end)
end
-- TODO what if already commented line has smallest indent?
-- TODO no tests for this indent block
local line_indent = v:match("^%s+") or ""
if not indent or string.len(line_indent) < string.len(indent) then
indent = line_indent
if not v:match("^%s*$") then
local line_indent = v:match("^%s+") or ""
if not indent or string.len(line_indent) < string.len(indent) then
indent = line_indent
end
end
end

Expand Down

0 comments on commit f3b39e0

Please sign in to comment.