mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
parent
1bd4642423
commit
13830e49b0
@ -74,6 +74,8 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand {
|
|||||||
modes = [Mode.Normal, Mode.Visual, Mode.VisualLine, Mode.VisualBlock];
|
modes = [Mode.Normal, Mode.Visual, Mode.VisualLine, Mode.VisualBlock];
|
||||||
override runsOnceForEachCountPrefix = false;
|
override runsOnceForEachCountPrefix = false;
|
||||||
abstract to: EditorScrollDirection;
|
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
|
* @returns the number of lines this command should move the cursor
|
||||||
@ -90,7 +92,9 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand {
|
|||||||
.getConfiguration('editor')
|
.getConfiguration('editor')
|
||||||
.get<boolean>('smoothScrolling', false);
|
.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);
|
const moveLines = timesToRepeat * this.getNumLines(visibleRanges);
|
||||||
|
|
||||||
let scrollLines = moveLines;
|
let scrollLines = moveLines;
|
||||||
@ -153,9 +157,10 @@ class CommandMoveFullPageDown extends CommandScrollAndMoveCursor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RegisterAction
|
@RegisterAction
|
||||||
class CommandMoveHalfPageDown extends CommandScrollAndMoveCursor {
|
class CommandCtrlD extends CommandScrollAndMoveCursor {
|
||||||
keys = ['<C-d>'];
|
keys = ['<C-d>'];
|
||||||
to: EditorScrollDirection = 'down';
|
to: EditorScrollDirection = 'down';
|
||||||
|
override setScroll = true;
|
||||||
|
|
||||||
protected getNumLines(visibleRanges: vscode.Range[]) {
|
protected getNumLines(visibleRanges: vscode.Range[]) {
|
||||||
return configuration.getScrollLines(visibleRanges);
|
return configuration.getScrollLines(visibleRanges);
|
||||||
@ -163,9 +168,10 @@ class CommandMoveHalfPageDown extends CommandScrollAndMoveCursor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RegisterAction
|
@RegisterAction
|
||||||
class CommandMoveHalfPageUp extends CommandScrollAndMoveCursor {
|
class CommandCtrlU extends CommandScrollAndMoveCursor {
|
||||||
keys = ['<C-u>'];
|
keys = ['<C-u>'];
|
||||||
to: EditorScrollDirection = 'up';
|
to: EditorScrollDirection = 'up';
|
||||||
|
override setScroll = true;
|
||||||
|
|
||||||
protected getNumLines(visibleRanges: vscode.Range[]) {
|
protected getNumLines(visibleRanges: vscode.Range[]) {
|
||||||
return configuration.getScrollLines(visibleRanges);
|
return configuration.getScrollLines(visibleRanges);
|
||||||
|
@ -2737,25 +2737,41 @@ suite('Mode Normal', () => {
|
|||||||
endMode: Mode.Normal,
|
endMode: Mode.Normal,
|
||||||
});
|
});
|
||||||
|
|
||||||
newTest({
|
suite('<C-u> / <C-d>', () => {
|
||||||
title: 'can handle <C-u> when first line is visible and starting column is at the beginning',
|
newTest({
|
||||||
start: ['\t hello world', 'hello', 'hi hello', '|foo'],
|
title: 'can handle <C-u> when first line is visible and starting column is at the beginning',
|
||||||
keysPressed: '<C-u>',
|
start: ['\t hello world', 'hello', 'hi hello', '|foo'],
|
||||||
end: ['\t |hello world', 'hello', 'hi hello', 'foo'],
|
keysPressed: '<C-u>',
|
||||||
});
|
end: ['\t |hello world', 'hello', 'hi hello', 'foo'],
|
||||||
|
});
|
||||||
|
|
||||||
newTest({
|
newTest({
|
||||||
title: 'can handle <C-u> when first line is visible and starting column is at the end',
|
title: 'can handle <C-u> when first line is visible and starting column is at the end',
|
||||||
start: ['\t hello world', 'hello', 'hi hello', 'very long line at the bottom|'],
|
start: ['\t hello world', 'hello', 'hi hello', 'very long line at the bottom|'],
|
||||||
keysPressed: '<C-u>',
|
keysPressed: '<C-u>',
|
||||||
end: ['\t |hello world', 'hello', 'hi hello', 'very long line at the bottom'],
|
end: ['\t |hello world', 'hello', 'hi hello', 'very long line at the bottom'],
|
||||||
});
|
});
|
||||||
|
|
||||||
newTest({
|
newTest({
|
||||||
title: 'can handle <C-u> when first line is visible and starting column is in the middle',
|
title: 'can handle <C-u> when first line is visible and starting column is in the middle',
|
||||||
start: ['\t hello world', 'hello', 'hi hello', 'very long line |at the bottom'],
|
start: ['\t hello world', 'hello', 'hi hello', 'very long line |at the bottom'],
|
||||||
keysPressed: '<C-u>',
|
keysPressed: '<C-u>',
|
||||||
end: ['\t |hello world', 'hello', 'hi hello', 'very long line at the bottom'],
|
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>', () => {
|
suite('<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[] {
|
function tokenizeKeySequence(sequence: string): string[] {
|
||||||
let isBracketedKey = false;
|
let isBracketedKey = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user