Skip to content

Fix non-ASCII path:line:column navigation#51238

Merged
SomeoneToIgnore merged 8 commits intozed-industries:mainfrom
loadingalias:cli-non-ascii-column-index
Mar 16, 2026
Merged

Fix non-ASCII path:line:column navigation#51238
SomeoneToIgnore merged 8 commits intozed-industries:mainfrom
loadingalias:cli-non-ascii-column-index

Conversation

@loadingalias
Copy link
Copy Markdown
Contributor

Closes #43329

Summary

This fixes path:line:column navigation for files containing non-ASCII text.

Before this change, open path flows were passing the external column directly into go_to_singleton_buffer_point. That happened to work for ASCII, but it was wrong for Unicode because external columns are user-visible character positions while the editor buffer stores columns as UTF-8 byte offsets.

This PR adds a shared text layer conversion for external row/column coordinates and uses it in the affected open-path flows:

  • file finder navigation
  • recent project remote connection navigation
  • recent project remote server navigation

It also adds regression coverage for the Unicode case that originally failed.

As a small - necessary - prerequisite, this also adds remote_connection test support to file_finder's dev-deps so the local regression test can build and run on this branch. That follows the same feature mismatch pattern previously fixed in #48280. I wasn't able to locally verify the tests/etc. w/o the addition... so I've rolled it into this PR. Tests are green.

The earlier attempt in #47093 was headed in the right direction, but it did not land and did not include the final regression coverage requested in review.

Verification

  • cargo fmt --all -- --check
  • ./script/clippy -p text
  • ./script/clippy -p file_finder
  • ./script/clippy -p recent_projects
  • cargo test -p file_finder --lib --no-run
  • cargo test -p file_finder file_finder_tests::test_row_column_numbers_query_inside_file -- --exact
  • cargo test -p file_finder file_finder_tests::test_row_column_numbers_query_inside_unicode_file -- --exact
  • cargo test -p text tests::test_point_for_row_and_column_from_external_source -- --exact

Manual

I reproduced locally on my machine (macOS) w/ a stateless launch using a Unicode file (Cyrillic)

Before:

  • :1:5 landed too far left
  • :1:10 landed around the 4th visible Cyrillic character

After:

  • :1:5 lands after 4 visible characters / before the 5th
  • :1:10 lands after 9 visible characters / before the 10th

Release Notes:

  • Fixed path:line:column navigation so non-ASCII columns land on the correct character.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 10, 2026
@maxdeviant maxdeviant changed the title fix non-ASCII path:line:column navigation Fix non-ASCII path:line:column navigation Mar 10, 2026
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Any chance we can address the #47093 (review) comment?

@SomeoneToIgnore SomeoneToIgnore self-assigned this Mar 11, 2026
@loadingalias
Copy link
Copy Markdown
Contributor Author

Any chance we can address the #47093 (review) comment?

I checked that old review comment again. This PR does add the missing failing regression coverage in file_finder for the Unicode path:line:column case.

The red CI is/was a separate regression on the existing out-of-bounds behavior, which I’ve now fixed (I think) by switching these open path flows to anchor based nav so EOF still clips correctly.

@loadingalias
Copy link
Copy Markdown
Contributor Author

I walked through the CI failures and pushed a follow-up fix.

Changes in the update:
• removed the unused text dependency that was tripping cargo-machete
• stopped using raw buffer points for these external path:line:column navigation paths
• switched those call sites to anchor-based navigation so EOF clipping still works correctly

That preserves the Unicode column fix from this PR and fixes the separate out-of-bounds regression that CI caught.

I'm still fairly new to the codebase, so if I missed anything or took the wrong approach, I’d appreciate the correction. Thanks!

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

No, that review comment asks to alter another module to reuse the same new code:

image

@loadingalias
Copy link
Copy Markdown
Contributor Author

No, that review comment asks to alter another module to reuse the same new code:

image

You were right. I misread that old review comment three times. Honestly, I think I just looked right over it to the last item in the thread. My mistake.

I now realize that go_to_line still had its own UTF-8 column conversion path. I’ve switched go_to_line to use the same external row/column conversion approach as the open path flows, added multibuffer coverage for the shared path, reran the targeted tests, and manually verified the behavior with a stateless build on my local machine.

Thanks for the correction and my bad for the oversight.

Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Great, thank you for covering all places.

A few minor things left to fix and we're ready to merge.

@loadingalias
Copy link
Copy Markdown
Contributor Author

loadingalias commented Mar 13, 2026

Thanks @SomeoneToIgnore. These were all good calls and exactly the kind of thing I need this early into the codebase. I will eliminate the waste as I get more familiar - thank you. So, I tightened the impl and pushed the follow up...

• restored the external nav call sites to go_to_singleton_buffer_point
• fixed the underlying EOF clipping issue in the point based path instead of keeping the temporary anchor based editor API
• removed the extra MultiBufferSnapshot external-column helper and kept the shared conversion at the text layer
• bounded the conversion scan using the UTF8 upper bound
• clipped the bounded end point through the buffer APIs so the helper never slices through a multibyte
• kept go_to_line UTF8 correct without broadening the API surface

I also reran the stateless zed /path/to/unicode.txt:1:1/5/10/999 launch path locally after the final fix and it's good.

If I've made errors or introduced waste/inefficiencies that you see - point them out and I'll circle back. Thanks a lot!

Note Obviously, the PR body is a bit stale. If you need it updated... let me know, but I imagine we're both on the same page - yes?

Edit Rebased onto current main and fixed a manifest conflict that surfaced

@loadingalias loadingalias force-pushed the cli-non-ascii-column-index branch from 72680ef to 67acad0 Compare March 13, 2026 20:20
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thank you!

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) March 16, 2026 12:37
@loadingalias
Copy link
Copy Markdown
Contributor Author

loadingalias commented Mar 16, 2026

You're welcome!

I noticed that the 'Tidy Up' commit looks to have broken the way the cursor mapping works, though? I think we need to restore inclusive endpoint handling in buffer_point_to_anchor, yeah?

The expected clamping behavior is defined in the test such that if the row/column are out of file bounds, they should clamp to last valid position (last row/last column). Isn't that the desired behavior here?

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

Thanks for noticing the culprit of the test failure: I have not found that particular change clear hence tried to revert.
Excerpts have exclusive ranges, so using = there feels wrong, as wrong is the fact that the 2nd conversion method was not updated to replicate the behavior.

I'm trying to think of other way to fix this all now.
Seems that file finder's confirm passes 0:18 correctly into go_to_singleton_buffer_point during this test?
I wonder if some .min or .clip_point or fallback is missing somewhere in the new calculation code?
Would be superb to hear your ideas and get a fix 🙂

@SomeoneToIgnore SomeoneToIgnore merged commit e5bb2c6 into zed-industries:main Mar 16, 2026
29 checks passed
@loadingalias
Copy link
Copy Markdown
Contributor Author

Tips Hat

Thanks for working with me, @SomeoneToIgnore. It's been a pleasure. After seeing the update, I understand. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

Status: Shipped by the Guild

Development

Successfully merging this pull request may close these issues.

zed cli column index broken on non ascii

3 participants