Skip to content

Commit d76d864

Browse files
committed
fix: local echo optimize
1 parent 9d357ef commit d76d864

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

frontend/src/components/XtermTerminal.vue

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,26 @@ const initTerminal = () => {
145145
term.loadAddon(webLinksAddon)
146146
147147
zerolag = new ZerolagInputAddon({
148-
prompt: { type: 'regex', pattern: /[$#%❯>]\s*$/, offset: 2 }
148+
prompt: {
149+
type: 'custom',
150+
find: (t) => {
151+
const buffer = t.buffer.active;
152+
const cursorY = buffer.cursorY;
153+
for (let y = cursorY; y >= Math.max(0, cursorY - 5); y--) {
154+
const line = buffer.getLine(y);
155+
if (line) {
156+
const str = line.translateToString(true);
157+
const match = str.match(/[$#%❯>]\s*$/);
158+
if (match) {
159+
return { row: y, col: match.index + match[0].length };
160+
}
161+
}
162+
}
163+
// Fallback to cursor position if prompt not recognized
164+
return { row: buffer.cursorY, col: buffer.cursorX };
165+
}
166+
},
167+
zIndex: 9999
149168
})
150169
term.loadAddon(zerolag)
151170

0 commit comments

Comments
 (0)