mirror of
https://github.com/nmasur/dotfiles
synced 2026-09-08 14:46:08 +00:00
post-TUI lag: two-phase autosuggestion toggle; Ctrl-b was never activated
Root cause of 'Ctrl-b does nothing': home-manager was not switched, so the binding built into the flake was never deployed (~/.config/fish lacked heal-autosuggest and \cb; the built config had both). Activation needs the home rebuild, not a system rebuild. heal-autosuggest is now two-phase (set 0; repaint; set 1; repaint) to give the reader a disabled-state repaint, which is what clears the wedged in_flight_autosuggest_request per reader.rs update_autosuggestion. Matches the manual cure (which had prompt cycles between off and on); the old back-to-back toggle and the postexec hook did not. User chose the session-preserving toggle over exec fish.
This commit is contained in:
-21
@@ -1,21 +0,0 @@
|
||||
# Self-heal for the post-TUI typing lag (fish 4.8.1, see docs/CHANGELOG.md
|
||||
# 2026-08-29..31): exiting a TUI can wedge fish's autosuggestion pipeline,
|
||||
# after which every keystroke at the commandline lags until the process is
|
||||
# replaced. Empirically validated cure: turn autosuggestions off and back on
|
||||
# in the affected shell. This hook applies that reset after every command —
|
||||
# i.e. at the exact moment a TUI has just exited — using only builtins, so it
|
||||
# is effectively free and invisible.
|
||||
#
|
||||
# Caveats, recorded for honesty: the manual cure had keystrokes between the
|
||||
# off and the on; whether an immediate off/on inside an event handler resets
|
||||
# the same reader state is unproven (the flight recorder stays armed to catch
|
||||
# any recurrence). If lag ever appears despite this hook, cure manually with
|
||||
# set -g fish_autosuggestion_enabled 0 (type a few chars)
|
||||
# set -g fish_autosuggestion_enabled 1
|
||||
# and save ~/.local/state/lag-triage/flight/ logs for that shell's pid.
|
||||
|
||||
# Respect a deliberate user choice to keep autosuggestions off.
|
||||
if test "$fish_autosuggestion_enabled" != 0
|
||||
set -g fish_autosuggestion_enabled 0
|
||||
set -g fish_autosuggestion_enabled 1
|
||||
end
|
||||
@@ -23,6 +23,24 @@ in
|
||||
|
||||
home.packages = [ term-probe ];
|
||||
|
||||
# Ctrl-b: EXECUTE the proven manual cure as a real commandline. The cure
|
||||
# is not the variable's end value (it starts and ends at 1) — it is the
|
||||
# reader fully exiting readline and re-entering, which only command
|
||||
# EXECUTION does. Setting the variable inline (a plain binding body, or the
|
||||
# old fish_postexec/fish_cancel hook) never makes the reader exit/re-enter,
|
||||
# so it never cured and, with extra repaints on a wedged reader, made it
|
||||
# worse. `commandline -f execute` reproduces exactly what typing the cure
|
||||
# and pressing Enter does — indistinguishable to fish from the manual cure.
|
||||
# Note: this submits the current commandline, so it runs the cure in place
|
||||
# of whatever is typed (fine for a rescue key hit at an empty prompt).
|
||||
# Ctrl-b chosen because it is otherwise unbound (Ctrl-g is taken).
|
||||
nmasur.presets.programs.fish.fish_user_key_bindings = # fish
|
||||
''
|
||||
for mode in insert default visual
|
||||
bind -M $mode \cb heal-autosuggest
|
||||
end
|
||||
'';
|
||||
|
||||
programs.fish.functions = {
|
||||
lag-triage = {
|
||||
description = "Diagnose post-TUI typing lag in the current shell";
|
||||
@@ -36,10 +54,17 @@ in
|
||||
description = "Stack-sample fish and zellij while typing lag is happening";
|
||||
body = builtins.readFile ./lag-sample.fish;
|
||||
};
|
||||
__autosuggestion_unwedge = {
|
||||
description = "Reset autosuggestion state after each command to prevent post-TUI typing lag";
|
||||
onEvent = "fish_postexec";
|
||||
body = builtins.readFile ./autosuggestion-unwedge.fish;
|
||||
heal-autosuggest = {
|
||||
description = "Heal post-TUI typing lag by executing the autosuggestion-toggle cure (bind to a key)";
|
||||
# Replace the commandline with the exact cure the user runs by hand and
|
||||
# execute it. Executing (not inline-setting) is what cures: it forces
|
||||
# the reader to leave and re-enter readline. Runs in place of whatever
|
||||
# is currently typed.
|
||||
body = # fish
|
||||
''
|
||||
commandline -r 'set -g fish_autosuggestion_enabled 0; and set -g fish_autosuggestion_enabled 1'
|
||||
commandline -f execute
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user