Skip to content

Topleftest Window Not Picked When actions.open_file.window_picker.enable false #1985

@alex-courtis

Description

@alex-courtis
Member

Discussed in #1983

Originally posted by paulrouget February 10, 2023
I have window_picker disabled. And the picked window is the most ancient window. Is it possible to automatically pick the most left-top window?

Activity

alex-courtis

alex-courtis commented on Feb 11, 2023

@alex-courtis
MemberAuthor

The topleftest window should be picked in this situation.

Looks like a bug with first_win_id not being called

local function get_target_winid(mode, win_ids)

changed the title [-]Anyway to automatically pick the most left window?[/-] [+]Topleftest Window Not Picked When `actions.open_file.window_picker.enable` false[/+] on Feb 11, 2023
alex-courtis

alex-courtis commented on Feb 12, 2023

@alex-courtis
MemberAuthor

Further experimentation indicates that nvim-tree attempts to use the most recently used window, then the topleftest.

Most recently used is set on open, focus etc. but not when manually moving to the nvim-tree window.

alex-courtis

alex-courtis commented on Feb 12, 2023

@alex-courtis
MemberAuthor

Tracking the previously focused window when entering the nvim-tree window is impractical via events.

Things are working exactly as per the doc, with the window from which the tree was opened being used:

            *nvim-tree.actions.open_file.window_picker.enable*
            Enable the feature. If the feature is not enabled, files will open in window
            from which you last opened the tree.
              Type: `boolean`, Default: `true`

@paulrouget could you live with using :NvimTreeFocus to navigate to nvim-tree?

paulrouget

paulrouget commented on Feb 13, 2023

@paulrouget

@paulrouget could you live with using :NvimTreeFocus to navigate to nvim-tree?

Absolutely! Changed my bindings to use :NvimTreeFocus instead of jumping to the window, and it works perfectly.

Thank you.

alex-courtis

alex-courtis commented on Feb 13, 2023

@alex-courtis
MemberAuthor

@paulrouget could you live with using :NvimTreeFocus to navigate to nvim-tree?

Absolutely! Changed my bindings to use :NvimTreeFocus instead of jumping to the window, and it works perfectly.

Thank you.

That's good to hear; there's no nice way to do it otherwise...

zhimsel

zhimsel commented on Jun 8, 2023

@zhimsel
Contributor

Is there really no way to open to the window that was previously active before selecting the nvim-tree window (regardless on navigation method)?

I have the same problem as @paulrouget, however I often use the mouse to start interacting with nvim-tree (to open a file, for instance). If I don't use :NvimTreeFocus, then it opens the file in the last window to have previously used :NvimTreeFocus (or presumably have been created by nvim-tree).

Would it be possible to use the lua equivalent of :winnr(#) (if it exists)?

Would it be possible to track the previous window by an event that fires every time you leave a window? Like maybe the WinLeave autocmd event? We could add another WinLeave autocmd similar to the one defined here, but using a negated pattern to ignore unwanted buffers like NvimTree_*.

alex-courtis

alex-courtis commented on Jun 10, 2023

@alex-courtis
MemberAuthor

@zhimsel it sounds like you have encountered a bug; the previously active window should be chosen when the window picker is disabled.

Please raise a Bug Report with minimal configuration and detailed replication instructions.

zhimsel

zhimsel commented on Jun 10, 2023

@zhimsel
Contributor

Please raise a Bug Report with minimal configuration and detailed replication instructions.

Done: #2262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreproducedIssue confirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @paulrouget@alex-courtis@zhimsel

        Issue actions

          Topleftest Window Not Picked When `actions.open_file.window_picker.enable` false · Issue #1985 · nvim-tree/nvim-tree.lua