mirror of https://github.com/lapce/lapce.git
Merge branch 'master' into zig_bash_treesitter
This commit is contained in:
commit
c3f67f75a3
|
@ -63,6 +63,7 @@ jobs:
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- name: Install dependencies on Ubuntu
|
- name: Install dependencies on Ubuntu
|
||||||
run: sudo apt-get update && sudo apt-get install cmake pkg-config libgtk-3-dev
|
run: sudo apt-get update && sudo apt-get install cmake pkg-config libgtk-3-dev
|
||||||
|
- uses: Swatinem/rust-cache@v1
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
|
|
|
@ -74,6 +74,28 @@ pub fn has_preview(&self) -> bool {
|
||||||
| PaletteType::Reference
|
| PaletteType::Reference
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the palette type that it should be considered as based on the current
|
||||||
|
/// [`PaletteType`] and the current input.
|
||||||
|
fn get_palette_type(current_type: &PaletteType, input: &str) -> PaletteType {
|
||||||
|
match current_type {
|
||||||
|
PaletteType::Reference | PaletteType::SshHost | PaletteType::Theme => {
|
||||||
|
return current_type.clone();
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
if input.is_empty() {
|
||||||
|
return PaletteType::File;
|
||||||
|
}
|
||||||
|
match input {
|
||||||
|
_ if input.starts_with('/') => PaletteType::Line,
|
||||||
|
_ if input.starts_with('@') => PaletteType::DocumentSymbol,
|
||||||
|
_ if input.starts_with('#') => PaletteType::WorkspaceSymbol,
|
||||||
|
_ if input.starts_with('>') => PaletteType::Workspace,
|
||||||
|
_ if input.starts_with(':') => PaletteType::Command,
|
||||||
|
_ => PaletteType::File,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
@ -678,13 +700,15 @@ pub fn update_input(&mut self, ctx: &mut EventCtx, input: String) {
|
||||||
let palette = Arc::make_mut(&mut self.palette);
|
let palette = Arc::make_mut(&mut self.palette);
|
||||||
|
|
||||||
// WorkspaceSymbol requires sending the query to the lsp, so we refresh it when the input changes
|
// WorkspaceSymbol requires sending the query to the lsp, so we refresh it when the input changes
|
||||||
if input != palette.input
|
// If the input changed and the palette type is still/now workspace-symbol then we rerun it
|
||||||
&& matches!(palette.palette_type, PaletteType::WorkspaceSymbol)
|
let palette_type =
|
||||||
{
|
PaletteType::get_palette_type(&palette.palette_type, &input);
|
||||||
|
if input != palette.input && palette_type == PaletteType::WorkspaceSymbol {
|
||||||
self.run(ctx, Some(PaletteType::WorkspaceSymbol), Some(input));
|
self.run(ctx, Some(PaletteType::WorkspaceSymbol), Some(input));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the current input
|
||||||
palette.input = input;
|
palette.input = input;
|
||||||
|
|
||||||
self.update_palette(ctx)
|
self.update_palette(ctx)
|
||||||
|
@ -693,7 +717,11 @@ pub fn update_input(&mut self, ctx: &mut EventCtx, input: String) {
|
||||||
pub fn update_palette(&mut self, ctx: &mut EventCtx) {
|
pub fn update_palette(&mut self, ctx: &mut EventCtx) {
|
||||||
let palette = Arc::make_mut(&mut self.palette);
|
let palette = Arc::make_mut(&mut self.palette);
|
||||||
palette.index = 0;
|
palette.index = 0;
|
||||||
let palette_type = self.get_palette_type();
|
|
||||||
|
let palette_type = PaletteType::get_palette_type(
|
||||||
|
&self.palette.palette_type,
|
||||||
|
&self.palette.input,
|
||||||
|
);
|
||||||
if self.palette.palette_type != palette_type {
|
if self.palette.palette_type != palette_type {
|
||||||
self.run(ctx, Some(palette_type), None);
|
self.run(ctx, Some(palette_type), None);
|
||||||
return;
|
return;
|
||||||
|
@ -710,26 +738,6 @@ pub fn update_palette(&mut self, ctx: &mut EventCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_palette_type(&self) -> PaletteType {
|
|
||||||
match self.palette.palette_type {
|
|
||||||
PaletteType::Reference | PaletteType::SshHost | PaletteType::Theme => {
|
|
||||||
return self.palette.palette_type.clone();
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
if self.palette.input.is_empty() {
|
|
||||||
return PaletteType::File;
|
|
||||||
}
|
|
||||||
match self.palette.input {
|
|
||||||
_ if self.palette.input.starts_with('/') => PaletteType::Line,
|
|
||||||
_ if self.palette.input.starts_with('@') => PaletteType::DocumentSymbol,
|
|
||||||
_ if self.palette.input.starts_with('#') => PaletteType::WorkspaceSymbol,
|
|
||||||
_ if self.palette.input.starts_with('>') => PaletteType::Workspace,
|
|
||||||
_ if self.palette.input.starts_with(':') => PaletteType::Command,
|
|
||||||
_ => PaletteType::File,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_files(&self, ctx: &mut EventCtx) {
|
fn get_files(&self, ctx: &mut EventCtx) {
|
||||||
let run_id = self.palette.run_id.clone();
|
let run_id = self.palette.run_id.clone();
|
||||||
let widget_id = self.palette.widget_id;
|
let widget_id = self.palette.widget_id;
|
||||||
|
|
Loading…
Reference in New Issue