Skip to content

Commit

Permalink
fix dg$ at the end of line (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed May 1, 2023
1 parent f35d20b commit a77ce37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cm_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ export class CodeMirror {
else if (name == "goLineLeft") cursorLineBoundaryBackward(this.cm6);
else if (name == "goLineRight") {
cursorLineBoundaryForward(this.cm6);
cursorCharBackward(this.cm6)
let state = this.cm6.state
let cur = state.selection.main.head;
if (cur < state.doc.length && state.sliceDoc(cur, cur + 1) !== "\n") {
cursorCharBackward(this.cm6);
}
}
else console.log(name + " is not implemented");
};
Expand Down
4 changes: 4 additions & 0 deletions test/vim_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ testVim('g0_g$', function(cm, vim, helpers) {
is(startCoords.left < endCoords.left);
is(startCoords.top == endCoords.top);
is(start.ch < end.ch && end.ch < cm.getValue().length / 2);
is(/\.$/.test(cm.getValue()));
helpers.doKeys('$', 'g', '0', 'd', 'g', '$');
is(!/\.$/.test(cm.getValue()));

},{ lineNumbers: false, lineWrapping:true, value: 'This line is long to test movement of g$ and g0 over wrapped lines.' });
testVim('}', function(cm, vim, helpers) {
cm.setCursor(0, 0);
Expand Down

0 comments on commit a77ce37

Please sign in to comment.