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:
parent
2e7bb11b7d
commit
37785a54d5
3 changed files with 152 additions and 31 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue