Skip to content

Commit 7b5d919

Browse files
committed
fix: selected_refactor and telescope extension after expr refactor
Fixes #501
1 parent 91dfdd1 commit 7b5d919

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lua/refactoring/init.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@ end
7878
function M.select_refactor(opts)
7979
local prefer_ex_cmd = opts and opts.prefer_ex_cmd or false
8080

81-
-- vim.ui.select exits visual mode without setting the `<` and `>` marks
82-
local utils = require("refactoring.utils")
83-
if utils.is_visual_mode() then
84-
utils.exit_to_normal_mode()
85-
end
86-
8781
require("plenary.async").void(function()
8882
local ui = require("refactoring.ui")
8983
local selected_refactor = ui.select(
@@ -103,7 +97,11 @@ function M.select_refactor(opts)
10397
require("refactoring.refactor").refactor_names[selected_refactor]
10498
api.nvim_input((":Refactor %s "):format(refactor_name))
10599
else
106-
M.refactor(selected_refactor, opts)
100+
local keys = M.refactor(selected_refactor, opts)
101+
if keys == "g@" then
102+
keys = "gvg@"
103+
end
104+
vim.cmd.normal(keys)
107105
end
108106
end)()
109107
end

lua/telescope/_extensions/refactoring.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ local function refactor(prompt_bufnr)
44
local content =
55
require("telescope.actions.state").get_selected_entry(prompt_bufnr)
66
require("telescope.actions").close(prompt_bufnr)
7-
refactoring.refactor(content.value)
7+
local keys = refactoring.refactor(content.value)
8+
9+
if keys == "g@" then
10+
keys = "gvg@"
11+
end
12+
vim.cmd.normal(keys)
813
end
914

1015
local function telescope_refactoring(opts)

0 commit comments

Comments
 (0)