Skip to content

[Discussion] unintuitive find_suitable_window logic for edit actions #287

@mrcjkb

Description

@mrcjkb

Problem

Quite often, I find myself launching the fff.nvim picker from a terminal buffer. When I select a file with <CR>, it opens the buffer in anther split that I have open.

I can see how this could be useful to prevent opening files in buffers like the quickfix list.
But more often than not, I actually want it to replace my buffer, even if it's not a "normal" buffer.
i.e., I'll end up with the following situation:

<regular_buffer> | <terminal_buffer>
...              |
...              | > | <- cursor is here

I want to open a file and replace the terminal buffer.
With the current implementation, I have to:

  • Close the terminal buffer
  • Create a new split and search the file I want to replace the terminal buffer with
  • Or, Search and use the keymap for opening in a vertical split

Neither is intuitive (and it's inconsistent with the behaviour of other pickers, like telescope.nvim).

I have the same issue with other buffers, like oil.nvim buffers (buftype = "acwrite").

Proposed solutions

  • Remove the logic altogether
  • Or, add a config option to disable it
  • Or, maintain a list of buffer types (e.g. quickfix) that trigger the find_suitable_buffer switching logic.
  • Or, maintain a list of suitable buffer types (e.g. terminal and acwrite)

Relevant code

fff.nvim/lua/fff/picker_ui.lua

Lines 2305 to 2308 in 64861f8

if current_buftype ~= '' or not current_buf_modifiable then
local suitable_win = find_suitable_window()
if suitable_win then vim.api.nvim_set_current_win(suitable_win) end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions