diff options
author | Guldoman <giulio.lettieri@gmail.com> | 2021-11-20 03:57:57 +0100 |
---|---|---|
committer | Guldoman <giulio.lettieri@gmail.com> | 2021-11-20 03:57:57 +0100 |
commit | 381b1b944dee3e054fd534d9622dc4cdbb184ab6 (patch) | |
tree | 018350bef4063184f66e2a76bad16c567ed1dbc3 /plugins/indent_convert.lua | |
parent | 4f31214e176156add0edb409910979ba09536d28 (diff) | |
download | lite-xl-plugins-381b1b944dee3e054fd534d9622dc4cdbb184ab6.tar.gz lite-xl-plugins-381b1b944dee3e054fd534d9622dc4cdbb184ab6.zip |
`indent_convert`: Restore selections
Diffstat (limited to 'plugins/indent_convert.lua')
-rw-r--r-- | plugins/indent_convert.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua index 6eb82b0..8d66033 100644 --- a/plugins/indent_convert.lua +++ b/plugins/indent_convert.lua @@ -7,6 +7,9 @@ config.plugins.indent_convert = { update_indent_type = true -- set to false to avoid updating the document indent type } +-- TODO: only set document indent type if there are no selections +-- TODO: correctly restore selections accounting for the offset caused by the conversion + -- To replace N spaces with tabs, we match the last N spaces before the start of -- the actual code and replace them with a tab. -- We repeat this until we can't find any more spaces before the code. @@ -82,7 +85,10 @@ end local function tabs_to_spaces() local doc = core.active_view.doc + local selections = doc.selections doc:replace(replacer(doc, tabs_replacer)) + doc.selections = selections + doc:sanitize_selection() if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "soft", @@ -94,7 +100,10 @@ end local function spaces_to_tabs() local doc = core.active_view.doc + local selections = doc.selections doc:replace(replacer(doc, spaces_replacer)) + doc.selections = selections + doc:sanitize_selection() if config.plugins.indent_convert.update_indent_type then doc.indent_info = { type = "hard", |