Skip to content
Open
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
8 changes: 6 additions & 2 deletions src/vs/editor/browser/coreCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { IViewModel } from '../common/viewModel.js';
import { ISelection } from '../common/core/selection.js';
import { getActiveElement, isEditableElement } from '../../base/browser/dom.js';
import { EnterOperation } from '../common/cursor/cursorTypeEditOperations.js';
import { TextEditorSelectionSource } from '../../platform/editor/common/editor.js';

const CORE_WEIGHT = KeybindingWeight.EditorCore;

Expand Down Expand Up @@ -604,13 +605,16 @@ export namespace CoreNavigationCommands {
}

private _runCursorMove(viewModel: IViewModel, source: string | null | undefined, args: CursorMove_.ParsedArguments): void {
// If noHistory is true, use PROGRAMMATIC source to prevent adding to navigation history
const effectiveSource = args.noHistory ? TextEditorSelectionSource.PROGRAMMATIC : source;

viewModel.model.pushStackElement();
viewModel.setCursorStates(
source,
effectiveSource,
CursorChangeReason.Explicit,
CursorMoveImpl._move(viewModel, viewModel.getCursorStates(), args)
);
viewModel.revealAllCursors(source, true);
viewModel.revealAllCursors(effectiveSource, true);
}

private static _move(viewModel: IViewModel, cursors: CursorState[], args: CursorMove_.ParsedArguments): PartialCursorState[] | null {
Expand Down
14 changes: 13 additions & 1 deletion src/vs/editor/common/cursor/cursorMoveCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ export namespace CursorMove {
return false;
}

if (!types.isUndefined(cursorMoveArg.noHistory) && !types.isBoolean(cursorMoveArg.noHistory)) {
return false;
}

return true;
};

Expand All @@ -626,6 +630,7 @@ export namespace CursorMove {
\`\`\`
* 'value': Number of units to move. Default is '1'.
* 'select': If 'true' makes the selection. Default is 'false'.
* 'noHistory': If 'true' does not add the movement to navigation history. Default is 'false'.
`,
constraint: isCursorMoveArgs,
schema: {
Expand All @@ -647,6 +652,10 @@ export namespace CursorMove {
'select': {
'type': 'boolean',
'default': false
},
'noHistory': {
'type': 'boolean',
'default': false
}
}
}
Expand Down Expand Up @@ -697,6 +706,7 @@ export namespace CursorMove {
select?: boolean;
by?: string;
value?: number;
noHistory?: boolean;
}

export function parse(args: Partial<RawArguments>): ParsedArguments | null {
Expand Down Expand Up @@ -777,7 +787,8 @@ export namespace CursorMove {
direction: direction,
unit: unit,
select: (!!args.select),
value: (args.value || 1)
value: (args.value || 1),
noHistory: (!!args.noHistory)
};
}

Expand All @@ -786,6 +797,7 @@ export namespace CursorMove {
unit: Unit;
select: boolean;
value: number;
noHistory: boolean;
}

export interface SimpleMoveArguments {
Expand Down