vim: :set support (#24209)

Closes #21147 

Release Notes:

- vim: First version of `:set` with support for `[no]wrap`,
`[no]number`, `[no]relativenumber`

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Max Bucknell 2025-02-10 20:55:40 -08:00 committed by GitHub
parent 2e7bb11b7d
commit 37785a54d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 152 additions and 31 deletions

View file

@ -108,7 +108,7 @@ pub struct CommandInterceptResult {
/// An interceptor for the command palette.
#[derive(Default)]
pub struct CommandPaletteInterceptor(
Option<Box<dyn Fn(&str, &App) -> Option<CommandInterceptResult>>>,
Option<Box<dyn Fn(&str, &App) -> Vec<CommandInterceptResult>>>,
);
#[derive(Default)]
@ -132,10 +132,12 @@ impl CommandPaletteInterceptor {
}
/// Intercepts the given query from the command palette.
pub fn intercept(&self, query: &str, cx: &App) -> Option<CommandInterceptResult> {
let handler = self.0.as_ref()?;
(handler)(query, cx)
pub fn intercept(&self, query: &str, cx: &App) -> Vec<CommandInterceptResult> {
if let Some(handler) = self.0.as_ref() {
(handler)(query, cx)
} else {
Vec::new()
}
}
/// Clears the global interceptor.
@ -146,7 +148,7 @@ impl CommandPaletteInterceptor {
/// Sets the global interceptor.
///
/// This will override the previous interceptor, if it exists.
pub fn set(&mut self, handler: Box<dyn Fn(&str, &App) -> Option<CommandInterceptResult>>) {
pub fn set(&mut self, handler: Box<dyn Fn(&str, &App) -> Vec<CommandInterceptResult>>) {
self.0 = Some(handler);
}
}