Skip to content

Commit

Permalink
Revert "improve selection-routine."
Browse files Browse the repository at this point in the history
This reverts commit ab46117.
  • Loading branch information
L3MON4D3 committed Oct 27, 2023
1 parent 7b05f6b commit ce3a5aa
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lua/luasnip/util/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,29 @@ local function restore_registers(restore_data)
end
end

-- subtle: `:lua` exits VISUAL, which means that the '< '>-marks (which we need
-- in pre_cut) will be set correctly!
-- subtle: `:lua` exits VISUAL, which means that the '< '>-marks will be set correctly!
-- Afterwards, we can just use <cmd>lua, which does not change the mode.
--
-- Also: yank to z, and then cut to blackhole. This is preferable to just
-- cutting to z immediately since it affects fewer registers.
M.select_keys =
[[:lua require("luasnip.util.select").pre_cut()<Cr>gv"zygv"_s<cmd>lua require('luasnip.util.select').post_cut("z")<Cr>]]
[[:lua require("luasnip.util.select").pre_cut()<Cr>gv"zs<cmd>lua require('luasnip.util.select').post_cut("z")<Cr>]]

local saved_registers
local lines
local start_line, start_col, end_line, end_col
local mode
function M.pre_cut()
-- store registers so we don't change any of them.
-- Since we yank to a named register and cut to the blackhole, only the
-- unnamed- and the z-register are changed (yank to named does not affect 0 or 1-9)
saved_registers = store_registers(
"",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"-",
"z"
)

Expand Down

0 comments on commit ce3a5aa

Please sign in to comment.