Skip to content

Commit cd0efe5

Browse files
authored
fix: suspend/restore set paste when loading picker UI (#334)
1 parent 541c3f5 commit cd0efe5

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

lua/fff/picker_ui.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,16 @@ end
442442
local preview_config = conf.get().preview
443443
if preview_config then preview.setup(preview_config) end
444444

445+
local function suspend_paste()
446+
if not vim.o.paste then return false end
447+
vim.o.paste = false
448+
return true
449+
end
450+
451+
local function restore_paste(should_restore)
452+
if should_restore then vim.o.paste = true end
453+
end
454+
445455
M.state = {
446456
active = false,
447457
layout = nil,
@@ -491,6 +501,7 @@ M.state = {
491501
ns_id = nil,
492502

493503
last_status_info = nil,
504+
restore_paste = false,
494505

495506
last_preview_file = nil,
496507
last_preview_location = nil, -- Track last preview location to detect changes
@@ -528,6 +539,9 @@ function M.create_ui()
528539
local config = M.state.config
529540
if not config then return false end
530541

542+
-- Prompt editing should behave consistently even if the user has :set paste.
543+
M.state.restore_paste = suspend_paste()
544+
531545
if not M.state.ns_id then
532546
M.state.ns_id = vim.api.nvim_create_namespace('fff_picker_status')
533547
combo_renderer.init(M.state.ns_id)
@@ -2411,6 +2425,8 @@ function M.close()
24112425
vim.cmd('stopinsert')
24122426
M.state.active = false
24132427

2428+
restore_paste(M.state.restore_paste)
2429+
24142430
combo_renderer.cleanup()
24152431
scrollbar.cleanup()
24162432

@@ -2478,6 +2494,7 @@ function M.close()
24782494
M.state.grep_regex_fallback_error = nil
24792495
M.state.suggestion_items = nil
24802496
M.state.suggestion_source = nil
2497+
M.state.restore_paste = false
24812498
M.state.combo_visible = true
24822499
M.state.combo_initial_cursor = nil
24832500
M.reset_history_state()

0 commit comments

Comments
 (0)