From 15b83aca5ffd3510a806c93513ecc37c6a0dd377 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Sat, 20 Dec 2014 13:11:31 -0800 Subject: [PATCH] fix move to EOL behaviour for visual block mode --- lib/ace/keyboard/vim.js | 6 +++++- lib/ace/keyboard/vim_test.js | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index d3a01ebc..ff054f96 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -2118,7 +2118,11 @@ dom.importCssString(".normal-mode .ace_cursor{\ newHead = copyCursor(origHead); } if (vim.visualMode) { - newHead = clipCursorToContent(cm, newHead, vim.visualBlock); + + if (!(vim.visualBlock && motion === "moveToEol")) { + newHead = clipCursorToContent(cm, newHead, vim.visualBlock); + } + if (newAnchor) { newAnchor = clipCursorToContent(cm, newAnchor, true); } diff --git a/lib/ace/keyboard/vim_test.js b/lib/ace/keyboard/vim_test.js index 7b51f23b..8b726a33 100644 --- a/lib/ace/keyboard/vim_test.js +++ b/lib/ace/keyboard/vim_test.js @@ -1957,6 +1957,14 @@ testVim('visual_line', function(cm, vim, helpers) { helpers.doKeys('l', 'V', 'l', 'j', 'j', 'd'); eq(' 4\n 5', cm.getValue()); }, { value: ' 1\n 2\n 3\n 4\n 5' }); +testVim('visual_block_move_to_eol', function(cm, vim, helpers) { + // moveToEol should move all block cursors to end of line + cm.setCursor(0, 0); + helpers.doKeys('', 'G', '$'); + var selections = cm.getSelections().join(); + console.log(selections); + eq("123,45,6", selections); +}, {value: '123\n45\n6'}); testVim('visual_block_different_line_lengths', function(cm, vim, helpers) { // test the block selection with lines of different length // i.e. extending the selection