From ae1697b6697e24c77fc852b02c760871db995a3f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 5 Feb 2015 14:57:32 +0000 Subject: Visual/edit modes: always fully remove the selection on exit from visual mode. There's considerable discussion in #1441 as to what we should do with the selection on leaving visual mode. Good arguments have been made as to why we should keep the selection. However, at this point, keep-it-simple seems like the best strategy, and wholly removing the selection (probably) provides fewer ways for the user to shoot themselves in the foot. --- content_scripts/mode_visual_edit.coffee | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee index c62fae87..7223e099 100644 --- a/content_scripts/mode_visual_edit.coffee +++ b/content_scripts/mode_visual_edit.coffee @@ -366,11 +366,7 @@ class Movement extends CountPrefix # returns it. yank: (args = {}) -> @yankedText = @selection.toString() - - if @options.deleteFromDocument or args.deleteFromDocument - @selection.deleteFromDocument() - else - @collapseSelectionToAnchor() + @selection.deleteFromDocument() if @options.deleteFromDocument or args.deleteFromDocument message = @yankedText.replace /\s+/g, " " message = message[...12] + "..." if 15 < @yankedText.length @@ -382,8 +378,10 @@ class Movement extends CountPrefix @yankedText exit: (event, target) -> - unless @options.parentMode or @options.oneMovementOnly - @selection.removeAllRanges() if event?.type == "keydown" and KeyboardUtils.isEscape event + @selection.removeAllRanges() unless @options.parentMode or @options.oneMovementOnly + # Disabled. We'll go with always removing the selection (as above), for now. + # unless @options.parentMode or @options.oneMovementOnly + # @selection.removeAllRanges() 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