Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lua/fff/picker_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@ end
local preview_config = conf.get().preview
if preview_config then preview.setup(preview_config) end

local function suspend_paste()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not to override it in the buffer local options? Doesn’t it work?

if not vim.o.paste then return false end
vim.o.paste = false
return true
end

local function restore_paste(should_restore)
if should_restore then vim.o.paste = true end
end

M.state = {
active = false,
layout = nil,
Expand Down Expand Up @@ -491,6 +501,7 @@ M.state = {
ns_id = nil,

last_status_info = nil,
restore_paste = false,

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

-- Prompt editing should behave consistently even if the user has :set paste.
M.state.restore_paste = suspend_paste()

if not M.state.ns_id then
M.state.ns_id = vim.api.nvim_create_namespace('fff_picker_status')
combo_renderer.init(M.state.ns_id)
Expand Down Expand Up @@ -2408,6 +2422,8 @@ function M.close()
vim.cmd('stopinsert')
M.state.active = false

restore_paste(M.state.restore_paste)

combo_renderer.cleanup()
scrollbar.cleanup()

Expand Down Expand Up @@ -2475,6 +2491,7 @@ function M.close()
M.state.grep_regex_fallback_error = nil
M.state.suggestion_items = nil
M.state.suggestion_source = nil
M.state.restore_paste = false
M.state.combo_visible = true
M.state.combo_initial_cursor = nil
M.reset_history_state()
Expand Down
Loading