Skip to content

Commit aa00a47

Browse files
authored
Fix preview bug (#3644)
* Fix preview bug * Add comment to empty case
1 parent 1df32c9 commit aa00a47

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

helix-term/src/commands/typed.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,10 @@ fn theme(
715715
cx.editor.unset_theme_preview();
716716
}
717717
PromptEvent::Update => {
718-
if let Some(theme_name) = args.first() {
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();
721+
} else if let Some(theme_name) = args.first() {
719722
if let Ok(theme) = cx.editor.theme_loader.load(theme_name) {
720723
if !(true_color || theme.is_16_color()) {
721724
bail!("Unsupported theme: theme requires true color support");

helix-term/src/ui/prompt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ impl Prompt {
293293
register: char,
294294
direction: CompletionDirection,
295295
) {
296+
(self.callback_fn)(cx, &self.line, PromptEvent::Abort);
296297
let register = cx.editor.registers.get_mut(register).read();
297298

298299
if register.is_empty() {
@@ -314,6 +315,7 @@ impl Prompt {
314315
self.history_pos = Some(index);
315316

316317
self.move_end();
318+
(self.callback_fn)(cx, &self.line, PromptEvent::Update);
317319
self.recalculate_completion(cx.editor);
318320
}
319321

@@ -564,13 +566,11 @@ impl Component for Prompt {
564566
ctrl!('p') | key!(Up) => {
565567
if let Some(register) = self.history_register {
566568
self.change_history(cx, register, CompletionDirection::Backward);
567-
(self.callback_fn)(cx, &self.line, PromptEvent::Update);
568569
}
569570
}
570571
ctrl!('n') | key!(Down) => {
571572
if let Some(register) = self.history_register {
572573
self.change_history(cx, register, CompletionDirection::Forward);
573-
(self.callback_fn)(cx, &self.line, PromptEvent::Update);
574574
}
575575
}
576576
key!(Tab) => {

0 commit comments

Comments
 (0)