aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqil Contractor <aqilcm@gmail.com>2023-01-21 22:50:07 -0500
committerGitHub <noreply@github.com>2023-01-21 22:50:07 -0500
commitbc047a8a0567e682568feb0c581b970565cd5664 (patch)
tree2a015e114465177d9073b55227926bc2d7cad7bf
parent3eb5ef21dcb560cf41e84f7cba37e957e5138502 (diff)
downloadlite-xl-plugins-bc047a8a0567e682568feb0c581b970565cd5664.tar.gz
lite-xl-plugins-bc047a8a0567e682568feb0c581b970565cd5664.zip
Fix `autoinsert.lua`'s behavior on multicursor (#195)
* Add guldo's godly changes * Fix autoinsert on multiple selections * Updated autoinsert to latest ver * FIX predicate solution * Appeal to the Guldo * Appeal to the Guldo even more
-rw-r--r--manifest.json2
-rw-r--r--plugins/autoinsert.lua6
2 files changed, 6 insertions, 2 deletions
diff --git a/manifest.json b/manifest.json
index ec27726..a2ffccf 100644
--- a/manifest.json
+++ b/manifest.json
@@ -9,7 +9,7 @@
},
{
"description": "Automatically inserts closing brackets and quotes. Also allows selected text to be wrapped with brackets or quotes.",
- "version": "0.1",
+ "version": "0.2",
"path": "plugins/autoinsert.lua",
"id": "autoinsert",
"mod_version": "3"
diff --git a/plugins/autoinsert.lua b/plugins/autoinsert.lua
index f6a8924..a210955 100644
--- a/plugins/autoinsert.lua
+++ b/plugins/autoinsert.lua
@@ -50,6 +50,10 @@ end
local on_text_input = DocView.on_text_input
function DocView:on_text_input(text)
+
+ -- Don't insert on multiselections
+ if #self.doc.selections > 4 then return on_text_input(self, text) end
+
local mapping = config.plugins.autoinsert.map[text]
-- prevents plugin from operating on `CommandView`
@@ -94,7 +98,7 @@ end
local function predicate()
return core.active_view:is(DocView)
- and not core.active_view.doc:has_selection(), core.active_view.doc
+ and #core.active_view.doc.selections <= 4 and not core.active_view.doc:has_selection(), core.active_view.doc
end
command.add(predicate, {