Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/cli/keyboard-shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ available combinations.

#### Basic Controls

| Action | Keys |
| --------------------------------------------------------------- | ---------- |
| Confirm the current selection or choice. | `Enter` |
| Dismiss dialogs or cancel the current focus. | `Esc` |
| Cancel the current request or quit the CLI when input is empty. | `Ctrl + C` |
| Exit the CLI when the input buffer is empty. | `Ctrl + D` |
| Action | Keys |
| --------------------------------------------------------------- | --------------------- |
| Confirm the current selection or choice. | `Enter` |
| Dismiss dialogs or cancel the current focus. | `Esc`<br />`Ctrl + [` |
| Cancel the current request or quit the CLI when input is empty. | `Ctrl + C` |
| Exit the CLI when the input buffer is empty. | `Ctrl + D` |

#### Cursor Movement

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/config/keyBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export type KeyBindingConfig = {
export const defaultKeyBindings: KeyBindingConfig = {
// Basic Controls
[Command.RETURN]: [{ key: 'return' }],
[Command.ESCAPE]: [{ key: 'escape' }],
[Command.ESCAPE]: [{ key: 'escape' }, { key: '[', ctrl: true }],
[Command.QUIT]: [{ key: 'c', ctrl: true }],
[Command.EXIT]: [{ key: 'd', ctrl: true }],

Expand Down
90 changes: 82 additions & 8 deletions packages/cli/src/ui/components/shared/text-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1657,8 +1657,9 @@ export type TextBufferAction =
| { type: 'vim_change_big_word_end'; payload: { count: number } }
| { type: 'vim_delete_line'; payload: { count: number } }
| { type: 'vim_change_line'; payload: { count: number } }
| { type: 'vim_delete_to_end_of_line' }
| { type: 'vim_change_to_end_of_line' }
| { type: 'vim_delete_to_end_of_line'; payload: { count: number } }
| { type: 'vim_delete_to_start_of_line' }
| { type: 'vim_change_to_end_of_line'; payload: { count: number } }
| {
type: 'vim_change_movement';
payload: { movement: 'h' | 'j' | 'k' | 'l'; count: number };
Expand Down Expand Up @@ -1688,6 +1689,11 @@ export type TextBufferAction =
| { type: 'vim_move_to_last_line' }
| { type: 'vim_move_to_line'; payload: { lineNumber: number } }
| { type: 'vim_escape_insert_mode' }
| { type: 'vim_delete_to_first_nonwhitespace' }
| { type: 'vim_change_to_start_of_line' }
| { type: 'vim_change_to_first_nonwhitespace' }
| { type: 'vim_delete_to_first_line'; payload: { count: number } }
| { type: 'vim_delete_to_last_line'; payload: { count: number } }
| {
type: 'toggle_paste_expansion';
payload: { id: string; row: number; col: number };
Expand Down Expand Up @@ -2437,6 +2443,7 @@ function textBufferReducerLogic(
case 'vim_delete_line':
case 'vim_change_line':
case 'vim_delete_to_end_of_line':
case 'vim_delete_to_start_of_line':
case 'vim_change_to_end_of_line':
case 'vim_change_movement':
case 'vim_move_left':
Expand All @@ -2463,6 +2470,11 @@ function textBufferReducerLogic(
case 'vim_move_to_last_line':
case 'vim_move_to_line':
case 'vim_escape_insert_mode':
case 'vim_delete_to_first_nonwhitespace':
case 'vim_change_to_start_of_line':
case 'vim_change_to_first_nonwhitespace':
case 'vim_delete_to_first_line':
case 'vim_delete_to_last_line':
return handleVimAction(state, action as VimAction);

case 'toggle_paste_expansion': {
Expand Down Expand Up @@ -2945,12 +2957,36 @@ export function useTextBuffer({
dispatch({ type: 'vim_change_line', payload: { count } });
}, []);

const vimDeleteToEndOfLine = useCallback((): void => {
dispatch({ type: 'vim_delete_to_end_of_line' });
const vimDeleteToEndOfLine = useCallback((count: number = 1): void => {
dispatch({ type: 'vim_delete_to_end_of_line', payload: { count } });
}, []);

const vimChangeToEndOfLine = useCallback((): void => {
dispatch({ type: 'vim_change_to_end_of_line' });
const vimDeleteToStartOfLine = useCallback((): void => {
dispatch({ type: 'vim_delete_to_start_of_line' });
}, []);

const vimChangeToEndOfLine = useCallback((count: number = 1): void => {
dispatch({ type: 'vim_change_to_end_of_line', payload: { count } });
}, []);

const vimDeleteToFirstNonWhitespace = useCallback((): void => {
dispatch({ type: 'vim_delete_to_first_nonwhitespace' });
}, []);

const vimChangeToStartOfLine = useCallback((): void => {
dispatch({ type: 'vim_change_to_start_of_line' });
}, []);

const vimChangeToFirstNonWhitespace = useCallback((): void => {
dispatch({ type: 'vim_change_to_first_nonwhitespace' });
}, []);

const vimDeleteToFirstLine = useCallback((count: number): void => {
dispatch({ type: 'vim_delete_to_first_line', payload: { count } });
}, []);

const vimDeleteToLastLine = useCallback((count: number): void => {
dispatch({ type: 'vim_delete_to_last_line', payload: { count } });
}, []);

const vimChangeMovement = useCallback(
Expand Down Expand Up @@ -3510,7 +3546,13 @@ export function useTextBuffer({
vimDeleteLine,
vimChangeLine,
vimDeleteToEndOfLine,
vimDeleteToStartOfLine,
vimChangeToEndOfLine,
vimDeleteToFirstNonWhitespace,
vimChangeToStartOfLine,
vimChangeToFirstNonWhitespace,
vimDeleteToFirstLine,
vimDeleteToLastLine,
vimChangeMovement,
vimMoveLeft,
vimMoveRight,
Expand Down Expand Up @@ -3592,7 +3634,13 @@ export function useTextBuffer({
vimDeleteLine,
vimChangeLine,
vimDeleteToEndOfLine,
vimDeleteToStartOfLine,
vimChangeToEndOfLine,
vimDeleteToFirstNonWhitespace,
vimChangeToStartOfLine,
vimChangeToFirstNonWhitespace,
vimDeleteToFirstLine,
vimDeleteToLastLine,
vimChangeMovement,
vimMoveLeft,
vimMoveRight,
Expand Down Expand Up @@ -3832,12 +3880,38 @@ export interface TextBuffer {
vimChangeLine: (count: number) => void;
/**
* Delete from cursor to end of line (vim 'D' command)
* With count > 1, deletes to end of current line plus (count-1) additional lines
*/
vimDeleteToEndOfLine: () => void;
vimDeleteToEndOfLine: (count?: number) => void;
/**
* Delete from start of line to cursor (vim 'd0' command)
*/
vimDeleteToStartOfLine: () => void;
/**
* Change from cursor to end of line (vim 'C' command)
* With count > 1, changes to end of current line plus (count-1) additional lines
*/
vimChangeToEndOfLine: (count?: number) => void;
/**
* Delete from cursor to first non-whitespace character (vim 'd^' command)
*/
vimDeleteToFirstNonWhitespace: () => void;
/**
* Change from cursor to start of line (vim 'c0' command)
*/
vimChangeToStartOfLine: () => void;
/**
* Change from cursor to first non-whitespace character (vim 'c^' command)
*/
vimChangeToFirstNonWhitespace: () => void;
/**
* Delete from current line to first line (vim 'dgg' command)
*/
vimDeleteToFirstLine: (count: number) => void;
/**
* Delete from current line to last line (vim 'dG' command)
*/
vimChangeToEndOfLine: () => void;
vimDeleteToLastLine: (count: number) => void;
/**
* Change movement operations (vim 'ch', 'cj', 'ck', 'cl' commands)
*/
Expand Down
Loading
Loading