From 7684019cb5d5c1d0ac5d7216653613220b4fd8d9 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 13 Jan 2015 05:50:18 +0000 Subject: Modes; enter insert mode if the selection changes. See discussion in #1415. --- content_scripts/mode_find.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'content_scripts') diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 30f136e9..519e99ad 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -12,6 +12,7 @@ class PostFindMode extends InsertModeBlocker constructor: (findModeAnchorNode) -> element = document.activeElement + initialSelection = window.getSelection().toString() super name: "post-find" @@ -20,6 +21,15 @@ class PostFindMode extends InsertModeBlocker singleton: PostFindMode exitOnBlur: element suppressPrintableEvents: element + # If the selection changes (e.g. via paste, or the arrow keys), then the user is interacting with the + # element, so get out of the way and activate insert mode. This implements 5c (without the input + # listener) as discussed in #1415. + keyup: => + @alwaysContinueBubbling => + if window.getSelection().toString() != initialSelection + @exit() + new InsertMode + targetElement: element return @exit() unless element and findModeAnchorNode -- cgit v1.2.3