From 865613d6d17bc4449784f34ada7adb83bdf94145 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 18 Apr 2015 10:48:40 +0100 Subject: 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. --- content_scripts/mode_visual_edit.coffee | 6 +++--- 1 file 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 -- cgit v1.2.3