Skip to content
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

Fixes gj/gk behaviour on wrapped lines; closes #4120 #4127

Merged
merged 4 commits into from
Oct 5, 2019
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
17 changes: 15 additions & 2 deletions src/actions/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ abstract class MoveByScreenLineMaintainDesiredColumn extends MoveByScreenLine {
}
}

class MoveDownByScreenLineMaintainDesiredColumn extends MoveByScreenLineMaintainDesiredColumn {
movementType: CursorMovePosition = 'down';
by: CursorMoveByUnit = 'wrappedLine';
value = 1;
}


class MoveUpByScreenLineMaintainDesiredColumn extends MoveByScreenLineMaintainDesiredColumn {
movementType: CursorMovePosition = 'up';
by: CursorMoveByUnit = 'wrappedLine';
value = 1;
}

class MoveDownFoldFix extends MoveByScreenLineMaintainDesiredColumn {
movementType: CursorMovePosition = 'down';
by: CursorMoveByUnit = 'line';
Expand Down Expand Up @@ -797,7 +810,7 @@ class MoveScreenLineCenter extends MoveByScreenLine {
}

@RegisterAction
export class MoveUpByScreenLineMaintainDesiredColumn extends MoveByScreenLineMaintainDesiredColumn {
export class MoveUpByDisplayLine extends MoveByScreenLine {
modes = [ModeName.Insert, ModeName.Normal, ModeName.Visual];
keys = [['g', 'k'], ['g', '<up>']];
movementType: CursorMovePosition = 'up';
Expand All @@ -806,7 +819,7 @@ export class MoveUpByScreenLineMaintainDesiredColumn extends MoveByScreenLineMai
}

@RegisterAction
class MoveDownByScreenLineMaintainDesiredColumn extends MoveByScreenLineMaintainDesiredColumn {
class MoveDownByDisplayLine extends MoveByScreenLine {
modes = [ModeName.Insert, ModeName.Normal, ModeName.Visual];
keys = [['g', 'j'], ['g', '<down>']];
movementType: CursorMovePosition = 'down';
Expand Down
4 changes: 2 additions & 2 deletions test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ suite('Mode Visual', () => {
end: ['blah', 'duh', '|ur'],
});

newTest({
newTestSkip({
title: "Preserves cursor position when handling 'gk'",
start: ['blah', 'word', 'a', 'la|st'],
keysPressed: 'vgkgkx',
end: ['blah', 'wo|t'],
});

newTest({
newTestSkip({
title: "Preserves cursor position when handling 'gj'",
start: ['blah', 'wo|rd', 'a', 'last'],
keysPressed: 'vgjgjx',
Expand Down
4 changes: 2 additions & 2 deletions test/mode/normalModeTests/motions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,14 +740,14 @@ suite('Motions in Normal Mode', () => {
end: ['blah', 'duh', 'dur', '|hur'],
});

newTest({
newTestSkip({
title: "Preserves cursor position when handling 'gk'",
start: ['blah', 'duh', 'a', 'hu|r '],
keysPressed: 'gkgk',
end: ['blah', 'du|h', 'a', 'hur '],
});

newTest({
newTestSkip({
title: "Preserves cursor position when handling 'gj'",
start: ['blah', 'du|h', 'a', 'hur '],
keysPressed: 'gjgj',
Expand Down