mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-10-26 12:06:48 +03:00
parent
1bd4642423
commit
13830e49b0
@ -74,6 +74,8 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand {
|
||||
modes = [Mode.Normal, Mode.Visual, Mode.VisualLine, Mode.VisualBlock];
|
||||
override runsOnceForEachCountPrefix = false;
|
||||
abstract to: EditorScrollDirection;
|
||||
/** if true, set scroll option instead of repeating command */
|
||||
setScroll = false;
|
||||
|
||||
/**
|
||||
* @returns the number of lines this command should move the cursor
|
||||
@ -90,7 +92,9 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand {
|
||||
.getConfiguration('editor')
|
||||
.get<boolean>('smoothScrolling', false);
|
||||
|
||||
const timesToRepeat = vimState.recordedState.count || 1;
|
||||
if (this.setScroll && vimState.recordedState.count)
|
||||
configuration.scroll = vimState.recordedState.count;
|
||||
const timesToRepeat = (!this.setScroll && vimState.recordedState.count) || 1;
|
||||
const moveLines = timesToRepeat * this.getNumLines(visibleRanges);
|
||||
|
||||
let scrollLines = moveLines;
|
||||
@ -153,9 +157,10 @@ class CommandMoveFullPageDown extends CommandScrollAndMoveCursor {
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
class CommandMoveHalfPageDown extends CommandScrollAndMoveCursor {
|
||||
class CommandCtrlD extends CommandScrollAndMoveCursor {
|
||||
keys = ['<C-d>'];
|
||||
to: EditorScrollDirection = 'down';
|
||||
override setScroll = true;
|
||||
|
||||
protected getNumLines(visibleRanges: vscode.Range[]) {
|
||||
return configuration.getScrollLines(visibleRanges);
|
||||
@ -163,9 +168,10 @@ class CommandMoveHalfPageDown extends CommandScrollAndMoveCursor {
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
class CommandMoveHalfPageUp extends CommandScrollAndMoveCursor {
|
||||
class CommandCtrlU extends CommandScrollAndMoveCursor {
|
||||
keys = ['<C-u>'];
|
||||
to: EditorScrollDirection = 'up';
|
||||
override setScroll = true;
|
||||
|
||||
protected getNumLines(visibleRanges: vscode.Range[]) {
|
||||
return configuration.getScrollLines(visibleRanges);
|
||||
|
@ -2737,6 +2737,7 @@ suite('Mode Normal', () => {
|
||||
endMode: Mode.Normal,
|
||||
});
|
||||
|
||||
suite('<C-u> / <C-d>', () => {
|
||||
newTest({
|
||||
title: 'can handle <C-u> when first line is visible and starting column is at the beginning',
|
||||
start: ['\t hello world', 'hello', 'hi hello', '|foo'],
|
||||
@ -2758,6 +2759,21 @@ suite('Mode Normal', () => {
|
||||
end: ['\t |hello world', 'hello', 'hi hello', 'very long line at the bottom'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: '[count]<C-u> sets and adheres to scroll option',
|
||||
start: ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'st|u'],
|
||||
keysPressed: '2<C-u><C-u>',
|
||||
end: ['abc', 'def', '|ghi', 'jkl', 'mno', 'pqr', 'stu'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: '[count]<C-d> sets and adheres to scroll option',
|
||||
start: ['ab|c', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu'],
|
||||
keysPressed: '2<C-d><C-d>',
|
||||
end: ['abc', 'def', 'ghi', 'jkl', '|mno', 'pqr', 'stu'],
|
||||
});
|
||||
});
|
||||
|
||||
suite('<C-g>', () => {
|
||||
// TODO: test with untitled file
|
||||
// TODO: test [count]<C-g>
|
||||
|
@ -149,7 +149,7 @@ class DocState {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize a string like "abc<Esc>d<C-c>" into ["a", "b", "c", "<Esc>", "d", "<C-c>"]
|
||||
* Tokenize a string like `"abc<Esc>d<C-c>"` into `["a", "b", "c", "<Esc>", "d", "<C-c>"]`
|
||||
*/
|
||||
function tokenizeKeySequence(sequence: string): string[] {
|
||||
let isBracketedKey = false;
|
||||
|
Loading…
Reference in New Issue
Block a user