Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:Neotree reveal dir=??? should not ask to change cwd #834

Closed
cseickel opened this issue Mar 29, 2023 · 2 comments
Closed

:Neotree reveal dir=??? should not ask to change cwd #834

cseickel opened this issue Mar 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@cseickel
Copy link
Contributor

cseickel commented Mar 29, 2023

If the user explicitly passed a directory to use as root, the command should not attempt to change the cwd automatically.

I see what's wrong, you found a bug. If you answer n to that prompt it would work correctly. The problem here is that the check for whether a reveled file is in the current working directory does not check the directory you requested as the root, it only checks what is your current working directory. I'll open a new issue for this.

Originally posted by @cseickel in #610 (comment)

@cseickel cseickel added the bug Something isn't working label Mar 29, 2023
@SamiKalliomaki
Copy link

I believe the problem is the path is not updated set when it read:

local cwd = state.path

The path is only updated later in the do_show_or_focus method.

@SamiKalliomaki
Copy link

I find I get decent behavior from this workaround

-- Copyright 2023 Google LLC.
-- SPDX-License-Identifier: Apache-2.0

function open_tree(args)
  local manager = require("neo-tree.sources.manager")
  local reveal_file = manager.get_path_to_reveal()

  if args.dir then
    -- Hack to work around a bug in neo-tree where it changes path too late for reveal
    state = manager.get_state(args.source, nil, nil)
    manager.navigate(state, args.dir, reveal_file, nil, false)
  end

  require("neo-tree.command").execute({
    dir = args.dir,
    source = args.source,
    reveal_file = reveal_file,
    reveal_force_cwd = true,
  })
end

pynappo pushed a commit that referenced this issue Jan 4, 2025
When `reveal_file` and `dir` are specified, `dir` will now always be changed to,
unless `reveal_force_cwd` was set.

Closes #1500, #834
Related to #1501
Co-authored-by: pynappo <[email protected]>
@pynappo pynappo closed this as completed Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants