aboutsummaryrefslogtreecommitdiff
path: root/plugins/bracketmatch.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-03-03 14:49:35 -0400
committerjgmdev <jgmdev@gmail.com>2022-03-03 14:49:35 -0400
commitc41660e8e16d0b5cde6431d37fcc8d0f4a703358 (patch)
tree070cc1bf116a6184838b4c4da3cc0c5f83f4e285 /plugins/bracketmatch.lua
parent05a871c163bbdb2281e6390c3230ff0fa53ecef9 (diff)
downloadlite-xl-plugins-c41660e8e16d0b5cde6431d37fcc8d0f4a703358.tar.gz
lite-xl-plugins-c41660e8e16d0b5cde6431d37fcc8d0f4a703358.zip
bracketmatch: implemented selection from #21 thanks to @mart-on-windows
Diffstat (limited to 'plugins/bracketmatch.lua')
-rw-r--r--plugins/bracketmatch.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/bracketmatch.lua b/plugins/bracketmatch.lua
index 4d1da37..b2c3f4e 100644
--- a/plugins/bracketmatch.lua
+++ b/plugins/bracketmatch.lua
@@ -36,6 +36,7 @@ end
local state = {}
+local select_adj = 0
local function update_state(line_limit)
line_limit = line_limit or math.huge
@@ -63,6 +64,8 @@ local function update_state(line_limit)
local open = doc.lines[line]:byte(col)
local close = map[open]
if close then
+ -- i == 0 if the cursor is on the left side of a bracket (or -1 when on right)
+ select_adj = i + 1 -- if i == 0 then select_adj = 1 else select_adj = 0 end
line2, col2 = get_matching_bracket(doc, line, col, line_limit, open, close, map.step)
goto found
end
@@ -113,6 +116,15 @@ command.add("core.docview", {
core.active_view.doc:set_selection(state.line2, state.col2)
end
end,
+ ["bracket-match:select-to-matching"] = function()
+ update_state()
+ if state.line2 then
+ core.active_view.doc:set_selection(state.line, state.col, state.line2, state.col2 + select_adj)
+ end
+ end,
})
-keymap.add { ["ctrl+m"] = "bracket-match:move-to-matching" }
+keymap.add {
+ ["ctrl+m"] = "bracket-match:move-to-matching",
+ ["ctrl+shift+m"] = "bracket-match:select-to-matching",
+}