From bc047a8a0567e682568feb0c581b970565cd5664 Mon Sep 17 00:00:00 2001 From: Aqil Contractor Date: Sat, 21 Jan 2023 22:50:07 -0500 Subject: 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 --- manifest.json | 2 +- plugins/autoinsert.lua | 6 +++++- 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, { -- cgit v1.2.3