Skip to content

Commit 4a78c33

Browse files
Añadir manejo de desplazamiento automático en el terminal al escribir y mover el cursor
1 parent 65e54a8 commit 4a78c33

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Server/src/terminal/terminalAddon.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ export class TerminalAddon implements ITerminalAddon {
222222
}
223223

224224
if (this.inputBuffer.length === this.cursor) {
225+
try {
226+
if (typeof (this.term as any).scrollToBottom === 'function') {
227+
(this.term as any).scrollToBottom();
228+
} else if (typeof (this.term as any).scrollLines === 'function') {
229+
(this.term as any).scrollLines(this.termSize.rows);
230+
}
231+
} catch (e) {
232+
// ignore
233+
}
225234
return;
226235
}
227236

@@ -233,6 +242,17 @@ export class TerminalAddon implements ITerminalAddon {
233242
if (cursorPosition.col > 0) {
234243
this.term.write(VT.CursorForward(cursorPosition.col));
235244
}
245+
246+
// Ensure the last line is visible after moving the cursor
247+
try {
248+
if (typeof (this.term as any).scrollToBottom === 'function') {
249+
(this.term as any).scrollToBottom();
250+
} else if (typeof (this.term as any).scrollLines === 'function') {
251+
(this.term as any).scrollLines(this.termSize.rows);
252+
}
253+
} catch (e) {
254+
// ignore
255+
}
236256
};
237257

238258
private calcCursorPosition(): TerminalPosition {

0 commit comments

Comments
 (0)