feat: 添加重置终端连接功能,确保连接前终端状态清晰
This commit is contained in:
1 parent
587899a77c
commit
2046674028
2 files changed
+12
-1
No files matched your search
@@ -7,6 +7,7 @@ import { decryptPasswordResult, encryptPassword, isEncryptedPassword } from './p
|
||||
import { resolveConnectionControl, resolveConnectionPanel } from './ui-state';
|
||||
import { classifyHostKey, SSH_FINGERPRINT_RE, type HostKeyPrompt } from './host-key';
|
||||
import { FileManager, collectFileManagerElements } from './file-manager';
|
||||
import { resetTerminalForConnection } from './terminal-session';
|
||||
import './style.css';
|
||||
|
||||
type AuthMethod = 'password' | 'publickey';
|
||||
@@ -1467,7 +1468,7 @@ async function connect(): Promise<void> {
|
||||
authorizationAbort = abortController;
|
||||
setState('connecting');
|
||||
ui.terminalEmpty.hidden = true;
|
||||
terminal.clear();
|
||||
resetTerminalForConnection(terminal);
|
||||
fitTerminal(false);
|
||||
|
||||
const host = normalizeHost(ui.host.value);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
const TERMINAL_RESET_SEQUENCE = '\x1bc';
|
||||
|
||||
interface WritableTerminal {
|
||||
write(data: string): void;
|
||||
}
|
||||
|
||||
export function resetTerminalForConnection(terminal: WritableTerminal): void {
|
||||
// Queue RIS behind pending SSH output so stale writes cannot land after the reset.
|
||||
terminal.write(TERMINAL_RESET_SEQUENCE);
|
||||
}
|
||||
Reference in new issue
Block a user