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

Reveal doesn't work with slach (/) separated path on Windows #478

Open
TisnKu opened this issue Jul 5, 2023 · 13 comments · May be fixed by #505
Open

Reveal doesn't work with slach (/) separated path on Windows #478

TisnKu opened this issue Jul 5, 2023 · 13 comments · May be fixed by #505
Labels
bug Something isn't working help wanted Extra attention is needed windows Windows specific issue

Comments

@TisnKu
Copy link

TisnKu commented Jul 5, 2023

Thanks for this plugin. I recently switched from nerdtree, it is so much faster.

Here is the issue. If I open a file via Fern explorer or Telescope search, then I can trigger Fern . -reveal=% -drawer -toggle to reveal current file. However, if the buffer is opened via diffview, then reveal won't work, it will always open the root directory and focus the root folder.

Steps to open a buffer via diffview:

  1. Setup up the plugin: use "sindrets/diffview.nvim"
  2. Open a git project and edit something
  3. Run :DiffviewOpen master to diff against master branch
  4. Press gf to go to selected file for editing
  5. In current buffer try to trigger Fern command to reveal it in directory
@lambdalisue
Copy link
Owner

What the value of expand('%') on the buffer opened via diffview? Fern use that value to determine what the actual file.

You can check it by

:echomsg expand('%')

On the buffer opened via diffview.

@TisnKu
Copy link
Author

TisnKu commented Jul 6, 2023

@lambdalisue It shows the file path correctly.
image

@TisnKu
Copy link
Author

TisnKu commented Jul 6, 2023

Nerdtree works with this situation though. Here is the link to the implementation: https://github.com/preservim/nerdtree/blob/c46e12a886b4a6618a9e834c90f6245952567115/autoload/nerdtree/ui_glue.vim#L296

@lambdalisue
Copy link
Owner

I could not reproduce the issue. Please make a minimal vimrc.

CleanShot.2023-07-06.at.19.05.48.mp4

@lambdalisue lambdalisue added the could not reproduce The issue is not reproducable label Jul 6, 2023
@TisnKu
Copy link
Author

TisnKu commented Jul 7, 2023

@lambdalisue Sorry for not clear enough about the repro steps. As long as you open the buffer before using diffview to open it, the issue cannot occur. So after git changes, simply reopen vim and use diffview to jump to that file directly.

@lambdalisue
Copy link
Owner

Could not reproduce.

CleanShot.2023-07-07.at.13.59.36.mp4

@TisnKu
Copy link
Author

TisnKu commented Jul 7, 2023

Here is a minimum init.lua for neovim. I figured out why you cannot repro. The issue exists only on windows powershell and not in wsl2 ubuntu.

image

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- Plugins
local ensure_packer = function()
  local fn = vim.fn
  local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
  if fn.empty(fn.glob(install_path)) > 0 then
    fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
    vim.cmd([[packadd packer.nvim]])
    return true
  end
  return false
end

local packer_bootstrap = ensure_packer()

-- Plugins
require("packer").startup(function(use)
  use("wbthomason/packer.nvim")

  use("lambdalisue/fern.vim")
  use("preservim/nerdtree")
  use { 'sindrets/diffview.nvim', requires = { 'nvim-lua/plenary.nvim' },
    config = function()
      require('diffview').setup()
    end
  }
  if packer_bootstrap then
    require("packer").sync()
  end
end)
-- End plugins

@lambdalisue lambdalisue added help wanted Extra attention is needed windows Windows specific issue labels Jul 8, 2023
@lambdalisue
Copy link
Owner

As long as you open the buffer before using diffview to open it, the issue cannot occur.


I figured out why you cannot repro. The issue exists only on windows powershell and not in wsl2 ubuntu.

Then, could you find the difference of expand('%') between before and after on windows powershell?

@TisnKu
Copy link
Author

TisnKu commented Jul 10, 2023

@lambdalisue There is a difference!
Using diffview to open a buffer shows the absolute path:
image

Directly open a buffer shows relative path:
image

@TisnKu
Copy link
Author

TisnKu commented Jul 10, 2023

The same difference exists on WSL2 but that does not seem to be a problem.

@lambdalisue
Copy link
Owner

So diffview opens a path separated by slash (/) even on windows but the proper path should be backslash (\) right?

@TisnKu
Copy link
Author

TisnKu commented Jul 10, 2023

@lambdalisue Exactly. Interesting that the buffer is opened succssfully with this path and NerdTree can still locate the file.

@lambdalisue lambdalisue removed the could not reproduce The issue is not reproducable label Jul 11, 2023
@lambdalisue lambdalisue changed the title Reveal current file does not work with buffer opened by diffview plugin Reveal doesn't work with slach (/) separated path on Windows Jul 11, 2023
@lambdalisue lambdalisue added the bug Something isn't working label Jul 11, 2023
@lambdalisue
Copy link
Owner

@TisnKu I'm sorry for late. While I could not reproduce the situation, I'm not sure if this change fixes your issue but could you try #505 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed windows Windows specific issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants