From 9bc02b6fe8329fc6342196070f68f1657075c3db Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 25 Mar 2016 11:38:18 +0000 Subject: Better choice of callapse on exit. The question here is where to callapse the selection to, anchor or focus? When exiting visual mode, mimic vim. When trasitioning between visual and caret modes, do what's right to keep the selection in the same place. This also adds some related tests. --- tests/dom_tests/dom_tests.coffee | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 517dce99..2311b768 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -744,12 +744,6 @@ context "Caret mode", By thy long grey beard and glittering eye, Now wherefore stopp'st thou me?

-

-      The Bridegroom's doors are opened wide,
-      And I am next of kin;
-      The guests are met, the feast is set:
-      May'st hear the merry din.
-    

""" initializeModeState() @initialVisualMode = new VisualMode @@ -793,6 +787,21 @@ context "Caret mode", sendKeyboardEvent "k" assert.equal "I", getSelection() + should "re-use an existing selection", -> + assert.equal "I", getSelection() + sendKeyboardEvents "ww" + assert.equal "a", getSelection() + sendKeyboardEvent "escape" + new VisualMode + assert.equal "a", getSelection() + + should "not move the selection on caret/visual mode toggle", -> + sendKeyboardEvents "ww" + assert.equal "a", getSelection() + for key in "vcvcvc".split() + sendKeyboardEvent key + assert.equal "a", getSelection() + context "Visual mode", setup -> document.getElementById("test-div").innerHTML = """ @@ -802,12 +811,6 @@ context "Visual mode", By thy long grey beard and glittering eye, Now wherefore stopp'st thou me?

-

-      The Bridegroom's doors are opened wide,
-      And I am next of kin;
-      The guests are met, the feast is set:
-      May'st hear the merry din.
-    

""" initializeModeState() @initialVisualMode = new VisualMode -- cgit v1.2.3