Skip to content

Conversation

@davidmh
Copy link
Contributor

@davidmh davidmh commented Apr 2, 2023

Hi @willothy,

Thank you for writing this plugin, it's has improved my workflow in a major way.

I noticed an unexpected behavior related to files from different working directories. When the terminal buffer changes directories, we should be able to open the intended file even if it matches the pathname in the Neovim current working directory.

And even when the resulting path doesn't match any files, it likely means I want to start a new file.

For example, having:

/tmp/example $ tree .
.
├── a
│   └── README.md
└── b
    └── README.md

2 directories, 2 files

/tmp/example $ cd a
/tmp/example/a $ vim README.md

In a terminal buffer:

/tmp/example/a $ cd ../b
/tmp/example/b $ vim README.md
/tmp/example/b $

I would expect /tmp/example/b/README.md to load in a new buffer, but I get /tmp/example/a/README.md instead.

When the terminal buffer changes directories, we should be able to open
the intended file even if it matches the pathname in the Neovim current
working directory.

And even when the resulting path doesn't match any files, it likely
means I want to start a new file.
Copy link
Owner

@willothy willothy left a comment

Choose a reason for hiding this comment

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

LGTM! I'll merge this later today. Thanks, not sure how I overlooked this haha

@willothy willothy merged commit fc9af19 into willothy:main Apr 3, 2023
@davidmh davidmh deleted the prioritize-guest-cwd branch April 3, 2023 16:03
davidmh added a commit to davidmh/flatten.nvim that referenced this pull request Apr 8, 2023
This is a follow-up to willothy#30.

Removing the `vim.loop.fs_realpath` check helps with relative paths that
exist in the guest, but it breaks absolute paths.

For example, in a neovim terminal

```shell
cd /tmp/
vim /tmp/a/file.txt
```

Would concatenate the path to `/tmp//tmp/a/file.

I'm guessing checking for the real path was supposed to handle that
scenario, it just conflicted with relative paths that matched the host
cwd.

This commit checks each file to see if it's absolute and avoid
prepending the guest cwd.
davidmh added a commit to davidmh/flatten.nvim that referenced this pull request Apr 8, 2023
This is a follow-up to willothy#30.

Removing the `vim.loop.fs_realpath` check helps with relative paths that
exist in the guest, but it breaks absolute paths.

For example, in a neovim terminal

```shell
cd /tmp/
vim /tmp/a/file.txt
```

Would concatenate the path to `/tmp//tmp/a/file.

I'm guessing checking for the real path was supposed to handle that
scenario, it just conflicted with relative paths that matched the host
cwd.

This commit checks each file to see if it's absolute and avoid
prepending the guest cwd.
davidmh added a commit to davidmh/flatten.nvim that referenced this pull request Apr 8, 2023
This is a follow-up to willothy#30.

Removing the `vim.loop.fs_realpath` check helps with relative paths that
exist in the guest, but it breaks absolute paths.

For example, in a neovim terminal

```shell
cd /tmp/
vim /tmp/a/file.txt
```

Would concatenate the path to `/tmp//tmp/a/file.

I'm guessing checking for the real path was supposed to handle that
scenario, it just conflicted with relative paths that matched the host
cwd.

This commit checks each file to see if it's absolute and avoid
prepending the guest cwd.
willothy pushed a commit that referenced this pull request Apr 8, 2023
This is a follow-up to #30.

Removing the `vim.loop.fs_realpath` check helps with relative paths that
exist in the guest, but it breaks absolute paths.

For example, in a neovim terminal

```shell
cd /tmp/
vim /tmp/a/file.txt
```

Would concatenate the path to `/tmp//tmp/a/file.

I'm guessing checking for the real path was supposed to handle that
scenario, it just conflicted with relative paths that matched the host
cwd.

This commit checks each file to see if it's absolute and avoid
prepending the guest cwd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants