Customized fork of github.com/rxi/lite

Changed `trimwhitespace` to never cause caret to reposition

rxi ae480496 6ec8fc56

Changed files
+7
data
+7
data/plugins/trimwhitespace.lua
··· 4 5 6 local function trim_trailing_whitespace(doc) 7 for i = 1, #doc.lines do 8 local old_text = doc:get_text(i, 1, i, math.huge) 9 local new_text = old_text:gsub("%s*$", "") 10 if old_text ~= new_text then 11 doc:insert(i, 1, new_text) 12 doc:remove(i, #new_text + 1, i, math.huge)
··· 4 5 6 local function trim_trailing_whitespace(doc) 7 + local cline, ccol = doc:get_selection() 8 for i = 1, #doc.lines do 9 local old_text = doc:get_text(i, 1, i, math.huge) 10 local new_text = old_text:gsub("%s*$", "") 11 + 12 + -- don't remove whitespace which would cause the caret to reposition 13 + if cline == i and ccol > #new_text then 14 + new_text = old_text:sub(1, ccol - 1) 15 + end 16 + 17 if old_text ~= new_text then 18 doc:insert(i, 1, new_text) 19 doc:remove(i, #new_text + 1, i, math.huge)