editor: In OpenFile check if file with path_suffix exists (#17805)
Demo: https://github.com/user-attachments/assets/6acb6c1e-bb15-4205-9dcb-2aa4bb99dcf9 Release Notes: - When using `OpenFile` (`gf` in Vim mode) and the word under the cursor is not an existing file path, we now fall back and additionally check whether a file called `<word-under-cursor>.<language-specific-path-suffixes>` exists. That's similar to Vim's `suffixesadd` option. --------- Co-authored-by: Abdelhakim Qbaich <abdelhakim@qbaich.com> Co-authored-by: Pete LeVasseur <plevasseur@gmail.com>
This commit is contained in:
parent
8f833ea029
commit
adbe973f02
3 changed files with 83 additions and 9 deletions
|
@ -969,6 +969,9 @@ mod test {
|
|||
fs.as_fake()
|
||||
.insert_file("/root/dir/file2.rs", "This is file2.rs".as_bytes().to_vec())
|
||||
.await;
|
||||
fs.as_fake()
|
||||
.insert_file("/root/dir/file3.rs", "go to file3".as_bytes().to_vec())
|
||||
.await;
|
||||
|
||||
// Put the path to the second file into the currently open buffer
|
||||
cx.set_state(indoc! {"go to fiˇle2.rs"}, Mode::Normal);
|
||||
|
@ -981,5 +984,21 @@ mod test {
|
|||
cx.workspace(|workspace, cx| {
|
||||
assert_active_item(workspace, "/root/dir/file2.rs", "This is file2.rs", cx);
|
||||
});
|
||||
|
||||
// Update editor to point to `file2.rs`
|
||||
cx.editor = cx.workspace(|workspace, cx| workspace.active_item_as::<Editor>(cx).unwrap());
|
||||
|
||||
// Put the path to the third file into the currently open buffer,
|
||||
// but remove its suffix, because we want that lookup to happen automatically.
|
||||
cx.set_state(indoc! {"go to fiˇle3"}, Mode::Normal);
|
||||
|
||||
// Go to file3.rs
|
||||
cx.simulate_keystrokes("g f");
|
||||
|
||||
// We now have three items
|
||||
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 3));
|
||||
cx.workspace(|workspace, cx| {
|
||||
assert_active_item(workspace, "/root/dir/file3.rs", "go to file3", cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue