pi-autosuggestions 0.3.1 → 0.3.2
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/README.md +10 -5
- package/extensions/autosuggestions.ts +44 -37
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{".":"0.3.
|
|
1
|
+
{".":"0.3.2"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.2](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.1...pi-autosuggestions-v0.3.2) (2026-09-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* use the terminal's native blinking bar cursor ([2abf68b](https://github.com/0xPlayerOne/pi-autosuggestions/commit/2abf68b1f226c9b62ec2c9cdebeb3375601de632))
|
|
9
|
+
|
|
3
10
|
## [0.3.1](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.0...pi-autosuggestions-v0.3.1) (2026-09-04)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -84,11 +84,16 @@ In bash mode (`!command`), a second strategy completes **filesystem paths**:
|
|
|
84
84
|
zero or one option → ghost, with history winning over paths
|
|
85
85
|
- Works for `!!` hidden commands and any bash argument, not just `cd`
|
|
86
86
|
|
|
87
|
-
###
|
|
88
|
-
|
|
89
|
-
The block cursor
|
|
90
|
-
|
|
91
|
-
character,
|
|
87
|
+
### Native blinking bar cursor
|
|
88
|
+
|
|
89
|
+
The editor's fake block cursor is replaced by your terminal's **native blinking
|
|
90
|
+
bar cursor** — the same behavior as Apple Terminal's bar style: it overlays the
|
|
91
|
+
cell edge without ever covering the character, blinks on its own, and pauses
|
|
92
|
+
blinking while you type. On ghost rows the bar rides the suggestion's first
|
|
93
|
+
character. The extension requests the blinking-bar shape via `DECSCUSR`
|
|
94
|
+
(`CSI 5 q`); terminals without that escape use their profile's cursor shape.
|
|
95
|
+
A software beam cursor is kept as a fallback if the hardware cursor is
|
|
96
|
+
unavailable.
|
|
92
97
|
|
|
93
98
|
## Attribution
|
|
94
99
|
|
|
@@ -52,9 +52,6 @@ class BashInlineEditor extends CustomEditor {
|
|
|
52
52
|
private ghost: Ghost | null = null;
|
|
53
53
|
private ghostToken = 0;
|
|
54
54
|
private ghostAbort?: AbortController;
|
|
55
|
-
private cursorOn = true;
|
|
56
|
-
private lastInputAt = 0;
|
|
57
|
-
private blinkTimer?: ReturnType<typeof setInterval>;
|
|
58
55
|
/** Submitted prompts, oldest first — the zsh-autosuggestions history strategy. */
|
|
59
56
|
private promptHistory: string[] = [];
|
|
60
57
|
/** Set by Escape; keeps the ghost dismissed until the next text edit. */
|
|
@@ -62,7 +59,12 @@ class BashInlineEditor extends CustomEditor {
|
|
|
62
59
|
|
|
63
60
|
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
|
|
64
61
|
super(tui, theme, keybindings);
|
|
65
|
-
|
|
62
|
+
// Native terminal cursor = the Apple-Terminal-style blinking bar: it
|
|
63
|
+
// draws over the glyph's cell edge without covering the character.
|
|
64
|
+
// DECSCUSR 5 q requests a blinking bar where the terminal supports
|
|
65
|
+
// it; otherwise the terminal profile's cursor shape is used as-is.
|
|
66
|
+
tui.setShowHardwareCursor(true);
|
|
67
|
+
tui.terminal.write("\x1b[5 q");
|
|
66
68
|
// Wrap onChange so programmatic text changes (paste, undo, history,
|
|
67
69
|
// setText) also refresh the inline suggestion.
|
|
68
70
|
let external: ((text: string) => void) | undefined;
|
|
@@ -117,9 +119,6 @@ class BashInlineEditor extends CustomEditor {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
handleInput(data: string): void {
|
|
120
|
-
// Solid cursor while typing; blinking resumes after the idle window.
|
|
121
|
-
this.lastInputAt = Date.now();
|
|
122
|
-
this.cursorOn = true;
|
|
123
122
|
// Accept keys while a ghost suggestion is showing and the cursor sits
|
|
124
123
|
// at end of line (zsh-autosuggestions widget semantics):
|
|
125
124
|
// right → accept the whole suggestion
|
|
@@ -181,54 +180,62 @@ class BashInlineEditor extends CustomEditor {
|
|
|
181
180
|
return out;
|
|
182
181
|
}
|
|
183
182
|
const head = row.slice(0, match.index);
|
|
183
|
+
const ch = match[1] || " ";
|
|
184
|
+
if (this.tui.getShowHardwareCursor()) {
|
|
185
|
+
// Native terminal cursor mode: strip the fake block so the real
|
|
186
|
+
// blinking bar is the only cursor. It overlays the cell edge
|
|
187
|
+
// without covering the character, and it rides the first ghost
|
|
188
|
+
// character on suggestion rows.
|
|
189
|
+
const ghost = this.activeGhost();
|
|
190
|
+
if (!ghost) {
|
|
191
|
+
// Empty cursor cell: the native bar blinks there, nothing covered.
|
|
192
|
+
out[rowIdx] = head + ch + row.slice(match.index + match[0].length);
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
// The ghost starts AT the cursor cell so the native bar overlays
|
|
196
|
+
// its first character (Apple Terminal bar-cursor behavior) instead
|
|
197
|
+
// of sitting in a gap cell.
|
|
198
|
+
const remainder = ghost.suggestion.slice(ghost.typed.length);
|
|
199
|
+
const pad = / *$/.exec(row.slice(match.index + match[0].length))?.[0].length ?? 0;
|
|
200
|
+
const avail = pad + 1;
|
|
201
|
+
let used = 0;
|
|
202
|
+
const ghostCells: string[] = [];
|
|
203
|
+
for (const g of [...remainder]) {
|
|
204
|
+
const w = visibleWidth(g);
|
|
205
|
+
if (used + w > avail) {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
ghostCells.push(`${DIM}${g}${RESET}`);
|
|
209
|
+
used += w;
|
|
210
|
+
}
|
|
211
|
+
out[rowIdx] = head + ghostCells.join("") + " ".repeat(Math.max(0, pad - used + 1));
|
|
212
|
+
return out;
|
|
213
|
+
}
|
|
184
214
|
const ghost = this.activeGhost();
|
|
185
215
|
if (ghost) {
|
|
186
|
-
//
|
|
187
|
-
// cell (frees 1 col) and render ghost chars into the padding.
|
|
216
|
+
// Fallback (software blink): ghost chars fill the padding.
|
|
188
217
|
const remainder = ghost.suggestion.slice(ghost.typed.length);
|
|
189
218
|
const pad = / *$/.exec(row.slice(match.index + match[0].length))?.[0].length ?? 0;
|
|
190
219
|
const avail = pad + 1;
|
|
191
220
|
let used = 0;
|
|
192
|
-
const
|
|
193
|
-
for (const
|
|
194
|
-
const w = visibleWidth(
|
|
221
|
+
const ghostCells: string[] = [];
|
|
222
|
+
for (const g of [...remainder]) {
|
|
223
|
+
const w = visibleWidth(g);
|
|
195
224
|
if (used + w > avail) {
|
|
196
225
|
break;
|
|
197
226
|
}
|
|
198
|
-
|
|
199
|
-
cells.push(used === 0 && this.cursorOn ? `\x1b[1m${ch}${RESET}` : `${DIM}${ch}${RESET}`);
|
|
227
|
+
ghostCells.push(`${DIM}${g}${RESET}`);
|
|
200
228
|
used += w;
|
|
201
229
|
}
|
|
202
|
-
out[rowIdx] = head +
|
|
230
|
+
out[rowIdx] = head + BEAM + ghostCells.join("") + " ".repeat(Math.max(0, pad - used));
|
|
203
231
|
return out;
|
|
204
232
|
}
|
|
205
|
-
|
|
206
|
-
// The beam only replaces empty cells — over a letter it would black
|
|
207
|
-
// the character out every other blink. Cursor over a letter instead
|
|
208
|
-
// renders that letter underlined while visible (zsh bar cursors draw
|
|
209
|
-
// the bar in the same cell; a terminal grid can't, so underline wins).
|
|
210
|
-
const cursorCell = this.cursorOn ? (ch === " " ? BEAM : `\x1b[4m${ch}${RESET}`) : ch;
|
|
211
|
-
out[rowIdx] = head + cursorCell + row.slice(match.index + match[0].length);
|
|
233
|
+
out[rowIdx] = head + BEAM + row.slice(match.index + match[0].length);
|
|
212
234
|
return out;
|
|
213
235
|
}
|
|
214
236
|
|
|
215
237
|
// --- internals ---
|
|
216
238
|
|
|
217
|
-
/** Toggle the beam cursor while focused; solid briefly after keystrokes. */
|
|
218
|
-
private startBlink(): void {
|
|
219
|
-
if (this.blinkTimer) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
this.blinkTimer = setInterval(() => {
|
|
223
|
-
if (!this.focused) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
const idle = Date.now() - this.lastInputAt > SOLID_AFTER_INPUT_MS;
|
|
227
|
-
this.cursorOn = idle ? !this.cursorOn : true;
|
|
228
|
-
this.tui.requestRender();
|
|
229
|
-
}, BLINK_INTERVAL_MS);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
239
|
private inBashMode(): boolean {
|
|
233
240
|
return this.getText().trimStart().startsWith("!");
|
|
234
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-autosuggestions",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "zsh-autosuggestions-style ghost completions for the pi coding agent — history-based inline suggestions, path completion in bash mode, blinking beam cursor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|