fix: delay shell command indicator to avoid flashes

This commit is contained in:
2026-10-18 01:19:07 +02:00
parent a5f92452b3
commit 00207b5526
3 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ Any other segment name is a custom named value, such as `:build_status`. Set ini
Move `:battery` to any anchor group or remove it from both bars to stop battery collection. A nonempty `config.labels[:battery]` or plugin value explicitly overrides the native text and pauses collection; clearing that value restores native readings. Other custom live values use [`editor.label(name, text)` or asynchronous plugin updates](plugins.md#named-label-updates). Configuration runs once at startup; there are no render callbacks. Move `:battery` to any anchor group or remove it from both bars to stop battery collection. A nonempty `config.labels[:battery]` or plugin value explicitly overrides the native text and pauses collection; clearing that value restores native readings. Other custom live values use [`editor.label(name, text)` or asynchronous plugin updates](plugins.md#named-label-updates). Configuration runs once at startup; there are no render callbacks.
`:shell` shows the pending `:!COMMAND` abbreviation and animated spinner, and hides when idle. It defaults to the right of `:battery`; move it to any anchor group or omit it without affecting command execution. A nonempty label named `shell` overrides the builtin display; clearing it restores the running indicator. `:shell` shows the pending `:!COMMAND` abbreviation and animated spinner only after the command has run for 200 ms, avoiding flashes for short commands. Completion output appears immediately, without waiting for that delay. The segment hides when idle. It defaults to the right of `:battery`; move it to any anchor group or omit it without affecting command execution. A nonempty label named `shell` overrides the builtin display; clearing it restores the running indicator.
### Command and search popup anchors ### Command and search popup anchors
+5 -2
View File
@@ -1782,9 +1782,12 @@ impl EditorSession {
self.editor.show_command_output(command, result); self.editor.show_command_output(command, result);
return true; return true;
} }
let elapsed = now.saturating_duration_since(*started);
if elapsed < Duration::from_millis(200) {
return false;
}
const FRAMES: [char; 4] = ['|', '/', '-', '\\']; const FRAMES: [char; 4] = ['|', '/', '-', '\\'];
let frame = let frame = FRAMES[((elapsed.as_millis() / 100) % 4) as usize];
FRAMES[((now.saturating_duration_since(*started).as_millis() / 100) % 4) as usize];
if self.editor.shell_label().ends_with(frame) { if self.editor.shell_label().ends_with(frame) {
return false; return false;
} }
+4 -2
View File
@@ -20,8 +20,10 @@ fn shell_commands_leave_editing_live_and_present_both_streams_and_exit_status()
session.handle(Input::Enter); session.handle(Input::Enter);
let fixed = Instant::now(); let fixed = Instant::now();
session.shell.as_mut().unwrap().2 = fixed; session.shell.as_mut().unwrap().2 = fixed;
assert!(session.poll_shell_at(fixed + Duration::from_millis(100))); assert!(!session.poll_shell_at(fixed + Duration::from_millis(199)));
assert_eq!(session.editor.shell_label(), "whi... /"); assert_eq!(session.editor.shell_label(), "");
assert!(session.poll_shell_at(fixed + Duration::from_millis(200)));
assert_eq!(session.editor.shell_label(), "whi... -");
session.execute("!printf should-not-run > unexpected"); session.execute("!printf should-not-run > unexpected");
assert_eq!( assert_eq!(
session.editor.message(), session.editor.message(),