Skip to content

Commit 347f8fd

Browse files
committed
fix: prevent Shift+Enter from consuming pending injection
- Add isNewlineInsert parameter to skip injection/telemetry on newline insert - Rename test file to match module (terminalKeybindings.test.ts)
1 parent d170d42 commit 347f8fd

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/renderer/terminal/TerminalSessionManager.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export class TerminalSessionManager {
145145
event.stopPropagation();
146146

147147
// Send Ctrl+J (line feed) instead of Shift+Enter
148-
this.handleTerminalInput(CTRL_J_ASCII);
148+
// Pass true to skip injection handling - this is a newline insert, not a submit
149+
this.handleTerminalInput(CTRL_J_ASCII, true);
149150
return false; // Prevent xterm from processing the Shift+Enter
150151
}
151152
return true; // Let xterm handle all other keys normally
@@ -312,7 +313,7 @@ export class TerminalSessionManager {
312313
};
313314
}
314315

315-
private handleTerminalInput(data: string) {
316+
private handleTerminalInput(data: string, isNewlineInsert: boolean = false) {
316317
this.emitActivity();
317318
if (this.disposed) return;
318319

@@ -321,18 +322,18 @@ export class TerminalSessionManager {
321322
const filtered = data.replace(/\x1b\[I|\x1b\[O/g, '');
322323
if (!filtered) return;
323324

324-
// Track command execution when Enter is pressed
325+
// Track command execution when Enter is pressed (but not for newline inserts)
325326
const isEnterPress = filtered.includes('\r') || filtered.includes('\n');
326-
if (isEnterPress) {
327+
if (isEnterPress && !isNewlineInsert) {
327328
void (async () => {
328329
const { captureTelemetry } = await import('../lib/telemetryClient');
329330
captureTelemetry('terminal_command_executed');
330331
})();
331332
}
332333

333-
// Check for pending injection text when Enter is pressed
334+
// Check for pending injection text when Enter is pressed (but not for newline inserts)
334335
const pendingText = pendingInjectionManager.getPending();
335-
if (pendingText && isEnterPress) {
336+
if (pendingText && isEnterPress && !isNewlineInsert) {
336337
// Append pending text to the existing input and keep the prior working behavior.
337338
const stripped = filtered.replace(/[\r\n]+$/g, '');
338339
const enterSequence = filtered.includes('\r') ? '\r' : '\n';
File renamed without changes.

0 commit comments

Comments
 (0)