vim: Keep command palette matches next to filename completions

With vim or helix mode on, searching the command palette for "split
selection" showed only a `:split selection` entry and hid
`editor: split selection into lines`. The vim interceptor reads the query
as `:split <file>`, and its filename completions were marked exclusive,
which drops every regular match. The same happens for other searches
that start with a filename command, like "edit prediction".

Return the completions as non-exclusive, like every other intercepted
command. They are still listed first, so `:sp foo` + enter behaves the
same.

Closes #64431
This commit is contained in:
dualfroz committed 2026-10-03 02:05:03 +02:00
1 parent 6ff5c0da84
commit 0b2a8d3999
1 file changed
+26 -1
+26 -1
View File
@@ -2023,9 +2023,11 @@ pub fn command_interceptor(
positions, positions,
}); });
} }
// Palette searches like "split selection" or "edit prediction" also
// parse as a command with a filename, so keep the regular matches.
CommandInterceptResult { CommandInterceptResult {
results, results,
exclusive: true, exclusive: false,
} }
}) })
} else { } else {
@@ -2634,6 +2636,7 @@ mod test {
use crate::{ use crate::{
VimAddon, VimAddon,
command::command_interceptor,
state::Mode, state::Mode,
test::{NeovimBackedTestContext, VimTestContext}, test::{NeovimBackedTestContext, VimTestContext},
}; };
@@ -2984,6 +2987,28 @@ mod test {
}); });
} }
#[gpui::test]
async fn test_filename_completions_keep_palette_matches(cx: &mut TestAppContext) {
let mut cx = VimTestContext::new(cx, true).await;
let workspace = cx.workspace(|_, _, cx| cx.weak_entity());
let intercept_result = cx
.update(|_, cx| command_interceptor("split selection", workspace, cx))
.await;
assert_eq!(
intercept_result
.results
.first()
.map(|item| item.string.as_str()),
Some(":split selection")
);
assert!(
!intercept_result.exclusive,
"filename completions must not hide the regular command palette matches"
);
}
#[gpui::test] #[gpui::test]
async fn test_command_write_filename(cx: &mut TestAppContext) { async fn test_command_write_filename(cx: &mut TestAppContext) {
let mut cx = VimTestContext::new(cx, true).await; let mut cx = VimTestContext::new(cx, true).await;