From 83fc0e58f6139ff5a1ae37fc300ea647da079171 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 5 Jun 2015 07:14:50 +0100 Subject: Global marks; always treat ` and ' as local marks. On some keyboards (who knows?) "`" or "'" could be shift keys. In this case, with the previous implementation, these would be treated as global marks and `` would be unusable. This commit fixes that problem. --- content_scripts/marks.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee index f569e1ea..067d05a8 100644 --- a/content_scripts/marks.coffee +++ b/content_scripts/marks.coffee @@ -23,6 +23,12 @@ Marks = showMessage: (message, keyChar) -> HUD.showForDuration "#{message} \"#{keyChar}\".", 1000 + # If is depressed, then it's a global mark, otherwise it's a local mark. This is consistent + # vim's [A-Z] for global marks and [a-z] for local marks. However, it also admits other non-Latin + # characters. The exceptions are "`" and "'", which are always considered local marks. + isGlobalMark: (event, keyChar) -> + event.shiftKey and keyChar not in @previousPositionRegisters + activateCreateMode: -> @mode = new Mode name: "create-mark" @@ -31,11 +37,8 @@ Marks = suppressAllKeyboardEvents: true keypress: (event) => keyChar = String.fromCharCode event.charCode - # If is depressed, then it's a global mark, otherwise it's a local mark. This is consistent - # vim's [A-Z] for global marks, [a-z] for local marks. However, it also admits other non-Latin - # characters. @exit => - if event.shiftKey + if @isGlobalMark event, keyChar # We record the current scroll position, but only if this is the top frame within the tab. # Otherwise, we'll fetch the scroll position of the top frame from the background page later. [ scrollX, scrollY ] = [ window.scrollX, window.scrollY ] if DomUtils.isTopFrame() @@ -58,7 +61,7 @@ Marks = keypress: (event) => @exit => keyChar = String.fromCharCode event.charCode - if event.shiftKey + if @isGlobalMark event, keyChar chrome.runtime.sendMessage handler: 'gotoMark' markName: keyChar -- cgit v1.2.3