Skip to content

Commit

Permalink
Merge pull request #2596 from hy950831/master
Browse files Browse the repository at this point in the history
add easymotion-lineforward and easymotion-linebackward
  • Loading branch information
xconverge committed May 6, 2018
2 parents 6ae22ea + 8be5d6e commit 57b2b46
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ Motion Command | Description
`<leader><leader> T <char>`|Til character backwards
`<leader><leader> w`|Start of word forwards
`<leader><leader> b`|Start of word backwards
`<leader><leader> l`|matches beginning & ending of word, camelCase, after _ and after # forwards
`<leader><leader> h`|matches beginning & ending of word, camelCase, after _ and after # backwards
`<leader><leader> e`|End of word forwards
`<leader><leader> ge`|End of word backwards
`<leader><leader> j`|Start of line forwards
Expand Down
14 changes: 14 additions & 0 deletions src/actions/plugins/easymotion/registerMoveActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ class EasyMotionStartOfWordBidirectionalCommand extends EasyMotionWordMoveComman
}
}

@RegisterAction
class EasyMotionLineForward extends EasyMotionWordMoveCommandBase {
constructor() {
super({ key: 'l' }, { jumpToAnywhere: true, searchOptions: 'min', labelPosition: 'after' });
}
}

@RegisterAction
class EasyMotionLineBackward extends EasyMotionWordMoveCommandBase {
constructor() {
super({ key: 'h' }, { jumpToAnywhere: true, searchOptions: 'max', labelPosition: 'after' });
}
}

// easymotion "JumpToAnywhere" motion

@RegisterAction
Expand Down
28 changes: 28 additions & 0 deletions test/plugins/easymotion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,32 @@ suite('easymotion plugin', () => {
keysPressed: easymotionCommand({ key: 'bdjk', leaderCount: 3 }, '', 'h'),
end: ['abc', 'def', 'ghi', '|jkl'],
});

newTest({
title: 'Can handle lineforward move (1)',
start: ['|abcDefGhi'],
keysPressed: easymotionCommand({ key: 'l', leaderCount: 2 }, '', 'h'),
end: ['abc|DefGhi'],
});

newTest({
title: 'Can handle lineforward move (2)',
start: ['|abcDefGhi'],
keysPressed: easymotionCommand({ key: 'l', leaderCount: 2 }, '', 'k'),
end: ['abcDef|Ghi'],
});

newTest({
title: 'Can handle linebackward move (1)',
start: ['abcDefGhi|'],
keysPressed: easymotionCommand({ key: 'h', leaderCount: 2 }, '', 'k'),
end: ['abc|DefGhi'],
});

newTest({
title: 'Can handle linebackward move (2)',
start: ['abcDefGhi|'],
keysPressed: easymotionCommand({ key: 'h', leaderCount: 2 }, '', 'h'),
end: ['abcDef|Ghi'],
});
});

0 comments on commit 57b2b46

Please sign in to comment.