on master help sign in
Fix preview bug (#3644)
aa00a47Joe
helix-term/src/commands/typed.rs+4−1
@@ -715,7 +715,10 @@ fn theme(
715 cx.editor.unset_theme_preview();
715 cx.editor.unset_theme_preview();
716 }
716 }
717 PromptEvent::Update => {
717 PromptEvent::Update => {
718+ if args.is_empty() {
719+ // Ensures that a preview theme gets cleaned up if the user backspaces until the prompt is empty.
720+ cx.editor.unset_theme_preview();
718− if let Some(theme_name) = args.first() {
721+ } else if let Some(theme_name) = args.first() {
719 if let Ok(theme) = cx.editor.theme_loader.load(theme_name) {
722 if let Ok(theme) = cx.editor.theme_loader.load(theme_name) {
720 if !(true_color || theme.is_16_color()) {
723 if !(true_color || theme.is_16_color()) {
721 bail!("Unsupported theme: theme requires true color support");
724 bail!("Unsupported theme: theme requires true color support");
helix-term/src/ui/prompt.rs+2−2
@@ -293,6 +293,7 @@ impl Prompt {
293 register: char,
293 register: char,
294 direction: CompletionDirection,
294 direction: CompletionDirection,
295 ) {
295 ) {
296+ (self.callback_fn)(cx, &self.line, PromptEvent::Abort);
296 let register = cx.editor.registers.get_mut(register).read();
297 let register = cx.editor.registers.get_mut(register).read();
297
298
298 if register.is_empty() {
299 if register.is_empty() {
@@ -314,6 +315,7 @@ impl Prompt {
314 self.history_pos = Some(index);
315 self.history_pos = Some(index);
315
316
316 self.move_end();
317 self.move_end();
318+ (self.callback_fn)(cx, &self.line, PromptEvent::Update);
317 self.recalculate_completion(cx.editor);
319 self.recalculate_completion(cx.editor);
318 }
320 }
319
321
@@ -564,13 +566,11 @@ impl Component for Prompt {
564 ctrl!('p') | key!(Up) => {
566 ctrl!('p') | key!(Up) => {
565 if let Some(register) = self.history_register {
567 if let Some(register) = self.history_register {
566 self.change_history(cx, register, CompletionDirection::Backward);
568 self.change_history(cx, register, CompletionDirection::Backward);
567− (self.callback_fn)(cx, &self.line, PromptEvent::Update);
568 }
569 }
569 }
570 }
570 ctrl!('n') | key!(Down) => {
571 ctrl!('n') | key!(Down) => {
571 if let Some(register) = self.history_register {
572 if let Some(register) = self.history_register {
572 self.change_history(cx, register, CompletionDirection::Forward);
573 self.change_history(cx, register, CompletionDirection::Forward);
573− (self.callback_fn)(cx, &self.line, PromptEvent::Update);
574 }
574 }
575 }
575 }
576 key!(Tab) => {
576 key!(Tab) => {