mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 07:29:42 +02:00
fix(terminal): let a composition-only overlay follow the prompt, repaint it on removeChar, document the API (#499 review)
Merge-time fixes for the three findings of the third review round of #499. - minor: a composition on an empty prompt did not follow the prompt after output or a resize. The post-write re-place in flushPendingWrites and the resize observer both ran rerender() only when hasPending was true, and hasPending deliberately excludes the composition, so the first word of a prompt (an overlay holding only a composition) stayed on the old row over whatever output moved there. Both sites now call rerender() unconditionally; it already returns early when there is nothing to draw, so nothing changes without a composition. New browser case drives the real batchTerminalWrite/flushPendingWrites path against real xterm 6 and the overlay built from source, moves the prompt from row 0 to row 3 and checks the overlay follows (it fails on the old guard, overlay left on row 0), with a parity case for pending text. The structure test pins the post-write site through vm and the resize site, which is a closure inside initTerminal(), by source. - nit: removeChar() dropped the composition but did not repaint on its false path, leaving a composition-only overlay on screen showing text the addon no longer held. It now hides the overlay there when a composition was dropped. Package tests cover that path and the flushed path repainting without the tail. - nit: the package README did not document setComposition() or the composition getter and described hasPending as "any content". Added both to the API tables plus a short IME composition section, reworded hasPending (pending or flushed text, excludes the composition), and made the quick start re-render unconditionally instead of teaching the hasPending guard. The hasPending JSDoc says the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1407,9 +1407,10 @@ Object.assign(CodemanApp.prototype, {
|
||||
// has to re-resolve their gate before the redraw, not just move them.
|
||||
this.applyLineageLineSettings?.();
|
||||
this.updateConnectionLines();
|
||||
if (this._localEchoOverlay?.hasPending) {
|
||||
this._localEchoOverlay.rerender();
|
||||
}
|
||||
// Unguarded on purpose: hasPending excludes an IME composition, so a
|
||||
// composition-only overlay would stay on the old prompt row. rerender()
|
||||
// is a no-op when the overlay has nothing to draw.
|
||||
this._localEchoOverlay?.rerender();
|
||||
// Pane B (split view) has its own container and its own fit()/resize
|
||||
// frame — this observer only ever measured Pane A's container, so
|
||||
// without this call Pane B never learned about a window resize, an
|
||||
@@ -4161,9 +4162,10 @@ Object.assign(CodemanApp.prototype, {
|
||||
|
||||
// Re-position local echo overlay after terminal writes — Ink redraws can
|
||||
// move the ❯ prompt to a different row, making the overlay invisible.
|
||||
if (this._localEchoOverlay?.hasPending) {
|
||||
this._localEchoOverlay.rerender();
|
||||
}
|
||||
// Unguarded on purpose: hasPending excludes an IME composition, so a
|
||||
// composition-only overlay (the first word of a prompt) would otherwise
|
||||
// stay on the old row. rerender() is a no-op when there is nothing to draw.
|
||||
this._localEchoOverlay?.rerender();
|
||||
|
||||
// After Tab completion: detect the completed text in the overlay.
|
||||
// Use terminal.write('', callback) to defer detection until xterm.js
|
||||
|
||||
Reference in New Issue
Block a user