<commit_before>
class PassKeysMode extends Mode
  constructor: ->
    super
      name: "passkeys"
      trackState: true # Maintain @enabled, @passKeys and @keyQueue.
      keydown: (event) => @handleKeyChar KeyboardUtils.getKeyChar event
      keypress: (event) => @handleKeyChar String.fromCharCode event.charCode
      keyup: (event) => @handleKeyChar String.fromCharCode event.charCode

  # Keystrokes are *never* considered passKeys if the keyQueue is not empty.  So, for example, if 't' is a
  # passKey, then 'gt' and '99t' will neverthless be handled by Vimium.
  handleKeyChar: (keyChar) ->
    if keyChar and not @keyQueue and 0 <= @passKeys.indexOf keyChar
      @stopBubblingAndTrue
    else
      @continueBubbling

  # Disabled, pending experimentation with how/whether to use badges (smblott, 2015/01/17).
  # updateBadge: (badge) ->
  #   badge.badge ||= "P" if @passKeys and not @keyQueue

root = exports ? window
root.PassKeysMode = PassKeysMode<commit_msg>Fix bug in mode_passkeys.<commit_after>
class PassKeysMode extends Mode
  constructor: ->
    super
      name: "passkeys"
      trackState: true # Maintain @enabled, @passKeys and @keyQueue.
      keydown: (event) => @handleKeyChar KeyboardUtils.getKeyChar event
      keypress: (event) => @handleKeyChar String.fromCharCode event.charCode
      keyup: (event) => @handleKeyChar KeyboardUtils.getKeyChar event

  # Keystrokes are *never* considered passKeys if the keyQueue is not empty.  So, for example, if 't' is a
  # passKey, then 'gt' and '99t' will neverthless be handled by Vimium.
  handleKeyChar: (keyChar) ->
    if keyChar and not @keyQueue and 0 <= @passKeys.indexOf keyChar
      @stopBubblingAndTrue
    else
      @continueBubbling

  # Disabled, pending experimentation with how/whether to use badges (smblott, 2015/01/17).
  # updateBadge: (badge) ->
  #   badge.badge ||= "P" if @passKeys and not @keyQueue

root = exports ? window
root.PassKeysMode = PassKeysMode
{'fraction_non_alphanumeric': 0.09591836734693877, 'fraction_numerical': 0.011224489795918367, 'mean_word_length': 3.7139423076923075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5432832', 'n_tokens_mistral': 639, 'n_tokens_neox': 615, 'n_words': 198}