diff options
| author | Francesco Abbate <francesco.bbt@gmail.com> | 2020-06-21 12:02:03 +0200 |
|---|---|---|
| committer | Francesco Abbate <francesco.bbt@gmail.com> | 2020-06-21 12:02:03 +0200 |
| commit | 0645ececf98867dd3ec13f3802cf74dedb7a444e (patch) | |
| tree | d01f8a38a49800bb2ac6bb84cbe26244f44abfb1 | |
| parent | c23ef761797cf31d1579aeab96e7857d32a2286d (diff) | |
| parent | ae48049695e2a74721323f608e439fb5f5b89da4 (diff) | |
| download | lite-xl-0645ececf98867dd3ec13f3802cf74dedb7a444e.tar.gz lite-xl-0645ececf98867dd3ec13f3802cf74dedb7a444e.zip | |
Merge remote-tracking branch 'rxi/master' into agg-font-renderer
| -rw-r--r-- | .github/FUNDING.yml | 3 | ||||
| -rw-r--r-- | data/plugins/trimwhitespace.lua | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..375655ac --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: rxi diff --git a/data/plugins/trimwhitespace.lua b/data/plugins/trimwhitespace.lua index ace1b0f8..d4d25c8f 100644 --- a/data/plugins/trimwhitespace.lua +++ b/data/plugins/trimwhitespace.lua @@ -4,9 +4,16 @@ local Doc = require "core.doc" local function trim_trailing_whitespace(doc) + local cline, ccol = doc:get_selection() for i = 1, #doc.lines do local old_text = doc:get_text(i, 1, i, math.huge) local new_text = old_text:gsub("%s*$", "") + + -- don't remove whitespace which would cause the caret to reposition + if cline == i and ccol > #new_text then + new_text = old_text:sub(1, ccol - 1) + end + if old_text ~= new_text then doc:insert(i, 1, new_text) doc:remove(i, #new_text + 1, i, math.huge) |
