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

fix : show short_file_name properly in Windows #35

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Jaehaks
Copy link

@Jaehaks Jaehaks commented May 15, 2024

/// Problem: #32

  1. Set configuration doesn't be applied in M.toggle_quick_menu()
    It makes short_file_name option don't work
  2. The number of slash('/') doesn't show properly in short_file_name mode.
    On Windows, sometimes the file path has both '/' and '\' as delimiter
    because of neovim inherit problem.

/// Solution:

  1. call get_config() function in toggle_quick_menu again. 2) On Windows, backslash of file path in buffer list is replaced by '/'

/// Problem:

1) Set configuration doesn't be applied in M.toggle_quick_menu()
    It makes short_file_name option don't work
2) The number of slash('/') doesn't show properly in short_file_name mode.
    On Windows, sometimes the file path has both '/' and '\\' as delimiter
    because of neovim inherit problem.

/// Solution:

1) call get_config() function in toggle_quick_menu again.
2) On Windows, backslash of file path in buffer list is replaced by '/'
@@ -299,6 +299,7 @@ end

function M.toggle_quick_menu()
log.trace("toggle_quick_menu()")
config = buffer_manager.get_config() -- update configuration
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure this is needed.

Copy link
Author

Choose a reason for hiding this comment

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

@j-morano
That is related with what I mentioned at Problem 1.
I agree with you that line(302) don't need If normal situation, because the same code exists at line(14).

But the configuration what I set doesn't apply whenever I call toggle_quick_menu(),
although the result of require('buffer_manager').get_config() in command mode is the same with what I configured.

For debugging, I wrote some print() code at line(302) like print(config.short_file_names). The result was false before I modified this line(302)

Does it works in your environment? If it does, I think It will be changed as
if vim.fn.has('win32') then config = buffer_manager.get_config() end
I am Windows 10 / nvim 0.9.5 / loading buffer_manager at startup

Choose a reason for hiding this comment

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

I'm warming up this discussion because I found a similar solution (see my fork) when trying to figure out why the width and height of the popup cannot be changed via the config.

I have little knowledge about lua but as far as I understand, the local config set in the top of the ui.lua file and used throughout it seems to be set before running any setup (at least when using lazy). So it always has the default values not matter what I set in the configuration. When getting the config in the function calls everything works as expected. So I think this and similar called in the other functions are very much needed. Or there is some more elegant solution one with lua experience can think of.

Also I'm using MacOS and Linux. So it is no Windows problem.

Choose a reason for hiding this comment

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

okay. Investigated a bit more and found that it was a configuration issue on my side. I called require("buffer_manager.ui") before running the setup. So I guess it is kind of expected. Still not the behaviour I would personally expect. It would certainly be cleaner if the config would be retrieved inside the function.

1) show parents if the file name is same even though slash_count is same

    6|test.lua
    7|test.lua (test/)

2) show parents continuously if the parents are same
    6|test.lua
    7|test.lua (kkk/test/)
it is same with #56b0f2b
But I missed this file update
@j-morano
Copy link
Owner

j-morano commented Feb 3, 2025

Hello. What is the status of this pull request? Does it introduce new functionality or just fix this issue for Windows?

@Jaehaks
Copy link
Author

Jaehaks commented Feb 9, 2025

@j-morano
This PR suggests dealing with short_file_names for Windows issue as you see...
short_file_names still doesn't work although 03df014 is commited.

toggle_quick_menu() show the relative path only when new buffer is added without the number of slash.
It remains showing absolute paths whenever I restart neovim and call the session opend before.
I think initializing of config has problem when execute toggle_quick_menu(), but it is weird because I don't know why the configuration cannot save as other plugins.

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.

3 participants