Add `config.keep_newline_whitespace` option (#1184)

This option will avoid removing line content when pressing enter in 
lines with only whitespace.
This commit is contained in:
Guldoman 2022-11-03 17:40:27 +01:00 committed by GitHub
parent b029f5993e
commit 03cc5ffcd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -287,7 +287,7 @@ local commands = {
indent = indent:sub(#indent + 2 - col) indent = indent:sub(#indent + 2 - col)
end end
-- Remove current line if it contains only whitespace -- Remove current line if it contains only whitespace
if dv.doc.lines[line]:match("^%s+$") then if not config.keep_newline_whitespace and dv.doc.lines[line]:match("^%s+$") then
dv.doc:remove(line, 1, line, math.huge) dv.doc:remove(line, 1, line, math.huge)
end end
dv.doc:text_input("\n" .. indent, idx) dv.doc:text_input("\n" .. indent, idx)

View File

@ -30,6 +30,7 @@ config.highlight_current_line = true
config.line_height = 1.2 config.line_height = 1.2
config.indent_size = 2 config.indent_size = 2
config.tab_type = "soft" config.tab_type = "soft"
config.keep_newline_whitespace = false
config.line_limit = 80 config.line_limit = 80
config.max_project_files = 2000 config.max_project_files = 2000
config.transitions = true config.transitions = true