-
Notifications
You must be signed in to change notification settings - Fork 91
Map Shift+Enter to newline #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f0a783b
Initial plan
Copilot 687ee19
Add Shift+Enter to Ctrl+J mapping for CLI agents
Copilot 7ffe23a
Refactor: Extract Shift+Enter check to helper method and use named co…
Copilot e1bc7c3
Improve code clarity: Better method name and comments
Copilot 323af59
Security: Update next from 16.0.8 to 16.0.9+ to fix DoS vulnerability
Copilot 0f56ffd
Add disposed check and test coverage for Shift+Enter mapping
Copilot 04f99c6
Fix Shift+Enter terminal input handling
notkainoa 1f916b0
Scope Shift+Enter mapping to CLI agent terminals
notkainoa 81068c8
Trim keybinding tests and drop docs lockfile churn
notkainoa 1712554
Restore monaco marker suppression comment
notkainoa d170d42
chore: format terminal keybindings
notkainoa 347f8fd
fix: prevent Shift+Enter from consuming pending injection
rabanspiegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| export type KeyEventLike = { | ||
| type: string; | ||
| key: string; | ||
| shiftKey?: boolean; | ||
| ctrlKey?: boolean; | ||
| metaKey?: boolean; | ||
| altKey?: boolean; | ||
| }; | ||
|
|
||
| // Ctrl+J sends line feed (LF) to the PTY, which CLI agents interpret as a newline | ||
| export const CTRL_J_ASCII = '\x0A'; | ||
|
|
||
| export function shouldMapShiftEnterToCtrlJ(event: KeyEventLike): boolean { | ||
| return ( | ||
| event.type === 'keydown' && | ||
| event.key === 'Enter' && | ||
| event.shiftKey === true && | ||
| !event.ctrlKey && | ||
| !event.metaKey && | ||
| !event.altKey | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| CTRL_J_ASCII, | ||
| shouldMapShiftEnterToCtrlJ, | ||
| type KeyEventLike, | ||
| } from '../../renderer/terminal/terminalKeybindings'; | ||
|
|
||
| describe('TerminalSessionManager - Shift+Enter to Ctrl+J mapping', () => { | ||
| const makeEvent = (overrides: Partial<KeyEventLike> = {}): KeyEventLike => ({ | ||
| type: 'keydown', | ||
| key: 'Enter', | ||
| shiftKey: false, | ||
| ctrlKey: false, | ||
| metaKey: false, | ||
| altKey: false, | ||
| ...overrides, | ||
| }); | ||
|
|
||
| it('maps Shift+Enter to Ctrl+J only', () => { | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ shiftKey: true }))).toBe(true); | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ shiftKey: false }))).toBe(false); | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ shiftKey: true, ctrlKey: true }))).toBe(false); | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ shiftKey: true, metaKey: true }))).toBe(false); | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ shiftKey: true, altKey: true }))).toBe(false); | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ key: 'a', shiftKey: true }))).toBe(false); | ||
| expect(shouldMapShiftEnterToCtrlJ(makeEvent({ type: 'keyup', shiftKey: true }))).toBe(false); | ||
| }); | ||
|
|
||
| it('uses line feed for Ctrl+J', () => { | ||
| expect(CTRL_J_ASCII).toBe('\n'); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.