Fix non-ASCII path:line:column navigation (#51238)
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. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
1 parent
52fb089258
commit
e5bb2c6790
12 files changed
+192
-39
No files matched your search
@@ -72,6 +72,30 @@ fn test_singleton(cx: &mut App) {
|
||||
assert_consistent_line_numbers(&snapshot);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_buffer_point_to_anchor_at_end_of_singleton_buffer(cx: &mut App) {
|
||||
let buffer = cx.new(|cx| Buffer::local("abc", cx));
|
||||
let multibuffer = cx.new(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
|
||||
let excerpt_id = multibuffer
|
||||
.read(cx)
|
||||
.excerpt_ids()
|
||||
.into_iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
let anchor = multibuffer
|
||||
.read(cx)
|
||||
.buffer_point_to_anchor(&buffer, Point::new(0, 3), cx);
|
||||
|
||||
assert_eq!(
|
||||
anchor,
|
||||
Some(Anchor::in_buffer(
|
||||
excerpt_id,
|
||||
buffer.read(cx).snapshot().anchor_after(Point::new(0, 3)),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_remote(cx: &mut App) {
|
||||
let host_buffer = cx.new(|cx| Buffer::local("a", cx));
|
||||
|
||||
Reference in new issue
Block a user