From ea43bf138015af760adca605692ab8876c969446 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 11 Nov 2017 19:05:59 +0000 Subject: Clear tabCount explicitly when needed, instead of implicitly and undoing This changes the behaviour of Enter and Space. * It should make no difference for Enter, as it exits the mode. * It makes no sense for rotating the layering of the hints to clear the active hint (when the next key is pressed), so I suspect it was an oversight. --- content_scripts/link_hints.coffee | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index f2fb7c19..291f524e 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -232,13 +232,9 @@ class LinkHintsMode onKeyDownInMode: (event) -> return if event.repeat - previousTabCount = @tabCount - @tabCount = 0 - # NOTE(smblott) The modifier behaviour here applies only to alphabet hints. if event.key in ["Control", "Shift"] and not Settings.get("filterLinkHints") and @mode in [ OPEN_IN_CURRENT_TAB, OPEN_WITH_QUEUE, OPEN_IN_NEW_BG_TAB, OPEN_IN_NEW_FG_TAB ] - @tabCount = previousTabCount # Toggle whether to open the link in a new or current tab. previousMode = @mode key = event.key @@ -262,6 +258,7 @@ class LinkHintsMode else if KeyboardUtils.isBackspace event if @markerMatcher.popKeyChar() + @tabCount = 0 @updateVisibleMarkers() else # Exit via @hintMode.exit(), so that the LinkHints.activate() "onExit" callback sees the key event and @@ -273,15 +270,14 @@ class LinkHintsMode HintCoordinator.sendMessage "activateActiveHintMarker" if @markerMatcher.activeHintMarker else if event.key == "Tab" - @tabCount = previousTabCount + (if event.shiftKey then -1 else 1) + if event.shiftKey then @tabCount-- else @tabCount++ @updateVisibleMarkers @tabCount else if event.key == " " and @markerMatcher.shouldRotateHints event - @tabCount = previousTabCount HintCoordinator.sendMessage "rotateHints" else - @tabCount = previousTabCount if event.ctrlKey or event.metaKey or event.altKey + @tabCount = 0 unless event.ctrlKey or event.metaKey or event.altKey unless event.repeat keyChar = if Settings.get "filterLinkHints" -- cgit v1.2.3 From 85f0ec02eafc60252e63667958b72188d697c423 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 11 Nov 2017 19:11:03 +0000 Subject: Remove unclear & unnecessary tabCount argument to updateVisibleMarkers --- content_scripts/link_hints.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 291f524e..118202aa 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -271,7 +271,7 @@ class LinkHintsMode else if event.key == "Tab" if event.shiftKey then @tabCount-- else @tabCount++ - @updateVisibleMarkers @tabCount + @updateVisibleMarkers() else if event.key == " " and @markerMatcher.shouldRotateHints event HintCoordinator.sendMessage "rotateHints" @@ -294,9 +294,10 @@ class LinkHintsMode handlerStack.suppressEvent - updateVisibleMarkers: (tabCount = 0) -> + updateVisibleMarkers: -> {hintKeystrokeQueue, linkTextKeystrokeQueue} = @markerMatcher - HintCoordinator.sendMessage "updateKeyState", {hintKeystrokeQueue, linkTextKeystrokeQueue, tabCount} + HintCoordinator.sendMessage "updateKeyState", + {hintKeystrokeQueue, linkTextKeystrokeQueue, tabCount: @tabCount} updateKeyState: ({hintKeystrokeQueue, linkTextKeystrokeQueue, tabCount}) -> extend @markerMatcher, {hintKeystrokeQueue, linkTextKeystrokeQueue} -- cgit v1.2.3 From f93410695cf5b62014cc9e37c0978c0e992b058e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 24 Nov 2017 09:35:09 +0000 Subject: Retain @tabCount unchanged for non-printable characters. Previously, @tabCount was reset on the `` `keydown` event, which defeats the purpose of #2792. Also, the @tabCount was reset on other non-printable characters such as ``. --- content_scripts/link_hints.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 118202aa..efb9239f 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -277,7 +277,6 @@ class LinkHintsMode HintCoordinator.sendMessage "rotateHints" else - @tabCount = 0 unless event.ctrlKey or event.metaKey or event.altKey unless event.repeat keyChar = if Settings.get "filterLinkHints" @@ -287,6 +286,7 @@ class LinkHintsMode if keyChar keyChar = " " if keyChar == "space" if keyChar.length == 1 + @tabCount = 0 @markerMatcher.pushKeyChar keyChar @updateVisibleMarkers() else -- cgit v1.2.3