From d9afc40a174122485dec73d2025fd8079fb58c88 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Thu, 9 Sep 2021 19:12:56 +0200 Subject: [PATCH] Bring back command find-replace:select-next Bring back the command like before to keep single selection but with ctrl+f3 keybindings. Change the name of the new multi-cursor command but keep the ctrl+d keybinding. --- changelog.md | 3 +++ data/core/commands/findreplace.lua | 10 ++++++++-- data/core/keymap-macos.lua | 5 +++-- data/core/keymap.lua | 5 +++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 2cf29061..5ea7b87c 100644 --- a/changelog.md +++ b/changelog.md @@ -35,6 +35,9 @@ Here some details about the bug fixes: - fix error that prevented the verification of plugins versions - fix error on X11 that caused a bug window event on exit +Change behavior of `ctrl+d` to add a multi-cursor selection to the next occurrence. +The old behavior to move the selection to the next occurrence is now done using the shortcut `ctrl+f3`. + ### 2.0 The 2.0 version of lite contains *breaking changes* to lite, in terms of how plugin settings are structured; diff --git a/data/core/commands/findreplace.lua b/data/core/commands/findreplace.lua index 902623be..c5f2bf07 100644 --- a/data/core/commands/findreplace.lua +++ b/data/core/commands/findreplace.lua @@ -160,8 +160,14 @@ local function select_next(all) end command.add(has_unique_selection, { - ["find-replace:select-next"] = function() select_next(false) end, - ["find-replace:select-all"] = function() select_next(true) end + ["find-replace:select-next"] = function() + local l1, c1, l2, c2 = doc():get_selection(true) + local text = doc():get_text(l1, c1, l2, c2) + l1, c1, l2, c2 = search.find(doc(), l2, c2, text, { wrap = true }) + if l2 then doc():set_selection(l2, c2, l1, c1) end + end, + ["find-replace:select-add-next"] = function() select_next(false) end, + ["find-replace:select-add-all"] = function() select_next(true) end }) command.add("core.docview", { diff --git a/data/core/keymap-macos.lua b/data/core/keymap-macos.lua index 7f54ddbb..53a20468 100644 --- a/data/core/keymap-macos.lua +++ b/data/core/keymap-macos.lua @@ -66,9 +66,10 @@ local function keymap_macos(keymap) ["cmd+shift+return"] = "doc:newline-above", ["cmd+j"] = "doc:join-lines", ["cmd+a"] = "doc:select-all", - ["cmd+d"] = { "find-replace:select-next", "doc:select-word" }, + ["cmd+d"] = { "find-replace:select-add-next", "doc:select-word" }, + ["cmd+f3"] = "find-replace:select-next", ["cmd+l"] = "doc:select-lines", - ["cmd+shift+l"] = { "find-replace:select-all", "doc:select-word" }, + ["cmd+shift+l"] = { "find-replace:select-add-all", "doc:select-word" }, ["cmd+/"] = "doc:toggle-line-comments", ["option+up"] = "doc:move-lines-up", ["option+down"] = "doc:move-lines-down", diff --git a/data/core/keymap.lua b/data/core/keymap.lua index 2be0dfc7..50eadec6 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -168,9 +168,10 @@ keymap.add_direct { ["ctrl+shift+return"] = "doc:newline-above", ["ctrl+j"] = "doc:join-lines", ["ctrl+a"] = "doc:select-all", - ["ctrl+d"] = { "find-replace:select-next", "doc:select-word" }, + ["ctrl+d"] = { "find-replace:select-add-next", "doc:select-word" }, + ["ctrl+f3"] = "find-replace:select-next", ["ctrl+l"] = "doc:select-lines", - ["ctrl+shift+l"] = { "find-replace:select-all", "doc:select-word" }, + ["ctrl+shift+l"] = { "find-replace:select-add-all", "doc:select-word" }, ["ctrl+/"] = "doc:toggle-line-comments", ["ctrl+up"] = "doc:move-lines-up", ["ctrl+down"] = "doc:move-lines-down",