From 5b460a07a0b2a72d3aa14cf1f414eb8cb24b7ae1 Mon Sep 17 00:00:00 2001 From: Alexander Lay-Calvert Date: Sat, 24 Sep 2022 22:12:58 -0400 Subject: [PATCH] Fixed bug with wrong visual ranges --- lua/telekasten.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 5e7678c..be00feb 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -2717,13 +2717,14 @@ local function ToggleTodo(opts) -- - [x] by - -- enter insert mode if opts.i == true opts = opts or {} - -- Neovim sends wrong visual selection when using a mapping - -- See https://github.com/neovim/neovim/issues/15144 - vim.cmd("execute 'normal! \\'") local startline = vim.api.nvim_buf_get_mark(0, "<")[1] local endline = vim.api.nvim_buf_get_mark(0, ">")[1] local cursorlinenr = vim.api.nvim_win_get_cursor(0)[1] - if startline == 0 or endline == 0 then + -- to avoid the visual range marks not being reset when calling + -- command from normal mode + vim.api.nvim_buf_set_mark(0, "<", 0, 0, {}) + vim.api.nvim_buf_set_mark(0, ">", 0, 0, {}) + if startline <= 0 or endline <= 0 then startline = cursorlinenr endline = cursorlinenr end