Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
fix: moving cursor when duplicating current line (#10)
Browse files Browse the repository at this point in the history
As opposed to all other cases, when duplicating the current line, the cursor is not moved to the duplicated content. This PR adds the missing movement one line down.
  • Loading branch information
chrisgrieser committed Jan 24, 2023
1 parent ba09f72 commit d58104c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/duplicate/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ local duplicate_cur_line = function()
end
local last_line = line_nr + line_count - 1
vim.api.nvim_buf_set_lines(0, last_line, last_line, false, lines)
-- Set Cursor to duplicated line
local cursor_line, cursor_col = unpack(vim.api.nvim_win_get_cursor(0))
vim.api.nvim_win_set_cursor(0, { cursor_line + line_count, cursor_col })
end

-- Line indices are 1-based, columns are 0-based
Expand Down

0 comments on commit d58104c

Please sign in to comment.