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(lsp,neotest): normalize file before root_dir comparison #245

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

bltavares
Copy link
Contributor

@bltavares bltavares commented Feb 20, 2024

In PR #152, rustacenavim begin storing the root_dir with a normalized disk drive format to avoid spawning multiple rust-analyzers while navigating files.

This change caused an unintend regression on the neotest integration, as
'vim.startswith' will not match the passed in path_files.

if root_dir and vim.startswith(file_path, root_dir) then

In summary, neotest would send the following:

:Neotest run file
-- -> file_path: C:\Users\me\repos\project\src\lib.rs
-- -> root_dir: c:\Users\me\projects\src\lib.rs
-- -> vim.startswith(file_path, root_dir) -- false
No tests found!

This commit changes the rust_analyzer function to ensure we use the normalized file path when performing the root_dir comparison, so we can find runnables from Neotest


Review Checklist

  • Pull request title has the appropriate conventional commit prefix.
    If applicable:
  • Tested
    • Tests have been added.
    • Tested manually (Steps to reproduce in PR description).
  • Updated documentation.
  • Updated CHANGELOG.md

@bltavares bltavares force-pushed the fix-file-normalization-neotest branch from 34db38a to ab71b22 Compare February 20, 2024 12:45
@bltavares bltavares changed the title Fix neotest integration on Windows fix(lsp,neotest): Normalize file before root_dir comparison Feb 20, 2024
@bltavares bltavares force-pushed the fix-file-normalization-neotest branch from ab71b22 to db3e1e6 Compare February 20, 2024 12:50
In PR mrcjkb#152, rustacenavim
begin storing the `root_dir` with a normalized disk drive format to
avoid spawning multiple rust-analyzers while navigating files.

This change caused an unintend regression on the neotest integration, as
'vim.startswith' will not match the passed in `path_files`.
https://github.com/mrcjkb/rustaceanvim/blob/4987d4159df2f80eb1deda1793ad54082d8ba454/lua/rustaceanvim/rust_analyzer.lua#L77

In summary, neotest would send the following:

```
:Neotest run file
-- -> file_path: C:\Users\me\repos\project\src\lib.rs
-- -> root_dir: c:\Users\me\projects\src\lib.rs
-- -> vim.startswith(file_path, root_dir) -- false
No tests found!
```

This commit changes the `rust_analyzer` function to ensure we use the
normalized file path when performing the root_dir comparisson, so we can
find runnables from Neotest
@bltavares bltavares force-pushed the fix-file-normalization-neotest branch from db3e1e6 to e37d39d Compare February 20, 2024 12:54
mrcjkb
mrcjkb previously approved these changes Feb 20, 2024
Copy link
Owner

@mrcjkb mrcjkb left a comment

Choose a reason for hiding this comment

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

Thanks 😄

@mrcjkb mrcjkb changed the title fix(lsp,neotest): Normalize file before root_dir comparison fix(lsp,neotest): normalize file before root_dir comparison Feb 20, 2024
Repository owner deleted a comment from github-actions bot Feb 20, 2024
@mrcjkb mrcjkb enabled auto-merge (squash) February 20, 2024 16:59
@mrcjkb mrcjkb disabled auto-merge February 20, 2024 16:59
@mrcjkb mrcjkb enabled auto-merge (squash) February 20, 2024 16:59
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