Skip to content

Conversation

@guanghechen
Copy link
Contributor

@guanghechen guanghechen commented Jun 17, 2025

RC: The vim.fs.normalize will return a invalid filepath in windows like C:\xxx\yyy\zzz

The new avante.utils.path module is modeled after Node.js's node:path API. I've been using this code in my personal Neovim configuration for over a year, and it has proven to be quite reliable for cross-platform path resolution and relative path handling.

@guanghechen guanghechen marked this pull request as draft June 17, 2025 05:08
@guanghechen guanghechen marked this pull request as ready for review June 17, 2025 05:30
@guanghechen
Copy link
Contributor Author

@yetone I have a confusion on the empty string path case, shouldn't it get . instead of ''? Since the normalize will always return . instead of

image

  it("should return empty string when no paths provided", function()
    local result = utils.join_paths()
    assert.equals("", result)
  end)

@yetone
Copy link
Owner

yetone commented Jun 17, 2025

@yetone I have a confusion on the empty string path case, shouldn't it get . instead of ''? Since the normalize will always return . instead of

image

  it("should return empty string when no paths provided", function()
    local result = utils.join_paths()
    assert.equals("", result)
  end)

It feels like there is no standard answer to this question.

image

@guanghechen
Copy link
Contributor Author

Yeah, but since there are already defined the behavior of the path.relative(empty string) to ., do you mind I change the test case to let the join_paths() return .?

image

@yetone yetone merged commit 436a02c into yetone:main Jun 17, 2025
3 checks passed
@brewinski
Copy link
Contributor

I think this might have introduced a bug when opening Avante with an empty buffer.

When I start Neovim and press aa, all of the files in the current directory are opened and I get the following error:
image

This is on MacOS 15. Anyone else running into this bug?

@guanghechen
Copy link
Contributor Author

will check it soon

@guanghechen
Copy link
Contributor Author

Hum, seems cannot repro it in my macos device

image

image

@guanghechen
Copy link
Contributor Author

I think I find what the issue is — is your current buffer a directory (like the cwd)? I believe that when opening Avante from a directory buffer, it shouldn't be added to the selected files list. will try to draft a pr to fix it.

@guanghechen
Copy link
Contributor Author

@brewinski can you try this fix?

#2254

@brewinski
Copy link
Contributor

Thanks @guanghechen for looking into this so quickly. Yes, #2254 change fixed the problem for me. :)

doodleEsc pushed a commit to doodleEsc/avante.nvim that referenced this pull request Jun 30, 2025
* fix(yetone#2094): fix the path resolving in windows

* fix test case

* tweak test case
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