diff options
| author | Stephen Blott | 2015-04-18 10:48:40 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-04-18 10:48:40 +0100 |
| commit | 865613d6d17bc4449784f34ada7adb83bdf94145 (patch) | |
| tree | 400a49dafbffa212f9896baed887224b65940ef5 | |
| parent | e5a2dee7d1a09d593cc721d9a6c8d95638270a76 (diff) | |
| download | vimium-865613d6d17bc4449784f34ada7adb83bdf94145.tar.bz2 | |
Selection handling on exiting visual mode.
Previously, we removed the selection on exiting visual mode. This
collapses the selection instead.
My own experience with visual mode suggests that this is better. In
particular, if we remove the selection, then when the user re-enters
visual mode, they're dropped into caret mode. It is unlikely that the
default caret position selected by caret mode is better than the last
text selected by the user in either caret mode or visual mode.
| -rw-r--r-- | content_scripts/mode_visual_edit.coffee | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee index a5758a64..f3f754af 100644 --- a/content_scripts/mode_visual_edit.coffee +++ b/content_scripts/mode_visual_edit.coffee @@ -366,12 +366,12 @@ class Movement extends CountPrefix # # End of Movement constructor. - # Yank the selection; always exits; either deletes the selection or removes it; set @yankedText and return + # Yank the selection; always exits; either deletes the selection or collapses it; set @yankedText and return # it. yank: (args = {}) -> @yankedText = @selection.toString() @selection.deleteFromDocument() if @options.deleteFromDocument or args.deleteFromDocument - @selection.removeAllRanges() unless @options.parentMode + @selection.collapseToStart() unless @options.parentMode message = @yankedText.replace /\s+/g, " " message = message[...12] + "..." if 15 < @yankedText.length @@ -384,7 +384,7 @@ class Movement extends CountPrefix exit: (event, target) -> unless @options.parentMode or @options.oneMovementOnly - @selection.removeAllRanges() if event?.type == "keydown" and KeyboardUtils.isEscape event + @selection.collapseToStart() if event?.type == "keydown" and KeyboardUtils.isEscape event # Disabled, pending discussion of fine-tuning the UX. Simpler alternative is implemented above. # # If we're exiting on escape and there is a range selection, then we leave it in place. However, an |
