Skip to content

Commit

Permalink
Fix case when '[' and ']' marks are messed up
Browse files Browse the repository at this point in the history
  • Loading branch information
backdround committed Oct 28, 2023
1 parent e0f3895 commit 6924d10
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lua/improved-search/search-operator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ local function get_subjected_lines(motion_type)
local start_line, start_column = get_mark("[")
local end_line, end_column = get_mark("]")

local swap = function()
start_line, end_line = end_line, start_line
start_column, end_column = end_column, start_column
end

if
start_line > end_line
or start_line == end_column and start_column > end_column
then
swap()
end

if motion_type == "line" then
return vim.api.nvim_buf_get_lines(0, start_line - 1, end_line, true)
elseif motion_type == "char" then
Expand Down

0 comments on commit 6924d10

Please sign in to comment.