terminal-ai-helper 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.3.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-ai-helper",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "The terminal that knows your next command Bash/Zsh suggestions that learn from your own history Offline and private with no account required",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -114,6 +114,26 @@ _tai_update() {
114
114
  fi
115
115
  return
116
116
  fi
117
+ # The accept echo is the one redraw that paints nothing. When the line is
118
+ # accepted, zsh re-renders it as it will run, and that render fires this
119
+ # hook — which answered it like any keystroke: it ran the query for the
120
+ # line one last time and painted the hint back onto the row the shell was
121
+ # leaving. The report: Enters on an empty prompt stacked gray `cd …` lines
122
+ # that read as commands the user ran, and a scrollback reader believed
123
+ # them. So the accept path raises _TAI_ACCEPT, and this hook takes tai's
124
+ # own paint down and stands aside: the echo shows what was typed, and what
125
+ # tai drew goes down with the line it rode in on. line-init lowers the
126
+ # flag with everything else it resets — the next line paints as usual.
127
+ if (( _TAI_ACCEPT )); then
128
+ _TAI_SUGGESTION=""
129
+ (( _TAI_MENU_IDX )) && _tai_menu_close
130
+ if (( _TAI_DREW )); then
131
+ POSTDISPLAY=""
132
+ region_highlight=()
133
+ _TAI_DREW=0
134
+ fi
135
+ return
136
+ fi
117
137
  local -i ours_was=$_TAI_DREW
118
138
  # What the last widget was decides whether this buffer is typed. The hook
119
139
  # runs after every widget, and the names here are the ones that mean an
@@ -348,10 +368,32 @@ tai-enter() {
348
368
  # A glimpsed menu still swallows the selection; Enter at a disarmed menu is
349
369
  # the line's Enter.
350
370
  if (( _TAI_MENU_IDX )); then _tai_menu_close; POSTDISPLAY=""; region_highlight=(); fi
371
+ # What runs is what was typed, and the echo of it must say so. zsh's final
372
+ # render of the accepted line fires the redraw hook, which would answer it
373
+ # with a fresh query and paint the hint back onto the row being left; the
374
+ # flag stands the hook down for that one render. See _tai_update.
375
+ _TAI_ACCEPT=1
351
376
  zle accept-line
352
377
  }
353
378
  zle -N tai-enter
354
379
 
380
+ # Enter is not the only door to a running line: TAI_NO_MENU=1 leaves ^M on
381
+ # stock accept-line, and so can a user binding of their own. The wrapper
382
+ # raises the same flag tai-enter raises, so the accept echo paints nothing
383
+ # in those shells either. It is registered only while the name is still the
384
+ # builtin — an accept-line another plugin wrapped is theirs, their clear
385
+ # already answers their own hint, and tai-enter raises the flag itself
386
+ # before it calls accept-line by name, so the hook stands down either way.
387
+ typeset -gi _TAI_ACCEPT=0
388
+ tai-accept-line() {
389
+ _TAI_ACCEPT=1
390
+ zle .accept-line
391
+ }
392
+ zle -N tai-accept-line
393
+ case "${widgets[accept-line]:-}" in
394
+ builtin*) zle -N accept-line tai-accept-line ;;
395
+ esac
396
+
355
397
  # Right arrow accepts the suggestion at the end of the line, and moves the
356
398
  # cursor one character anywhere else. Bound straight to tai-accept it took
357
399
  # forward-char away entirely: with a ghost on screen there was then no key left
@@ -560,6 +602,10 @@ _tai_line_init() {
560
602
  # exit hook, and a flag carried into the next line would stand tai down for
561
603
  # every keystroke of it. The hook pair is the truth; this is the belt.
562
604
  _TAI_ISEARCH=0
605
+ # Nor is a line still being accepted: the accept flag stands the redraw
606
+ # hook down for the echo of the line that is leaving, and a new line is
607
+ # painted on again from its first redraw.
608
+ _TAI_ACCEPT=0
563
609
  region_highlight=()
564
610
  _tai_menu_close
565
611
  # The prophecy. _TAI_SEQ answers "what did I run after this", and the fresh