philc/vimium · error · Error

The linkHintNumbers setting must have more than 1 character.

Error message

The linkHintNumbers setting must have more than 1 character.

What it means

FilterHints generates numeric link-hint strings from the linkHintNumbers setting for filter-based hint mode. With 1 or fewer characters every hint would be a prefix of another ('1', '11', ...), making hints ambiguous, so the constructor throws as a fail-fast check on the setting. It is a settings-validation error, not a runtime logic failure.

Source

Thrown at content_scripts/link_hints.js:930

  popKeyChar() {
    return this.hintKeystrokeQueue.pop();
  }

  // For alphabet hints, <Space> always rotates the hints, regardless of modifiers.
  shouldRotateHints() {
    return true;
  }
}

// Use characters for hints, and also filter links by their text.
class FilterHints {
  constructor() {
    this.linkHintNumbers = Settings.get("linkHintNumbers").toUpperCase();
    // Ensure we have more than 1 character to generate hint strings. With 1 character, every hint
    // will be another hint's prefix ("1", "11", ...).
    if (this.linkHintNumbers.length <= 1) {
      throw new Error("The linkHintNumbers setting must have more than 1 character.");
    }

    this.hintKeystrokeQueue = [];
    this.linkTextKeystrokeQueue = [];
    this.activeHintMarker = null;
    // The regexp for splitting typed text and link texts. We split on sequences of non-word
    // characters and link-hint numbers.
    this.splitRegexp = new RegExp(
      `[\\W${Utils.escapeRegexSpecialCharacters(this.linkHintNumbers)}]+`,
    );
  }

  generateHintString(linkHintNumber) {
    const base = this.linkHintNumbers.length;
    const hint = [];
    while (linkHintNumber > 0) {
      hint.push(this.linkHintNumbers[Math.floor(linkHintNumber % base)]);
      linkHintNumber = Math.floor(linkHintNumber / base);

View on GitHub (pinned to 5aa29614bf)

Solutions

  1. Set linkHintNumbers in the extension options to at least 2 characters (default is '0123456789').
  2. If the setting was corrupted by import/sync, reset hint settings to defaults.
  3. In code/tests, verify Settings.get('linkHintNumbers').length > 1 before creating FilterHints.
  4. Catch the error and fall back to the default numeric character set.

Example fix

// before
Settings.set('linkHintNumbers', '1');
new FilterHints(); // throws

// after
Settings.set('linkHintNumbers', '0123456789');
new FilterHints(); // ok
Defensive patterns

Strategy: validation

Validate before calling

const nums = (Settings.get('linkHintNumbers') || '').toUpperCase();
if (typeof nums !== 'string' || nums.length <= 1) {
  throw new Error('linkHintNumbers must contain at least 2 characters');
}

Type guard

function hasValidHintNumbers(value) {
  return typeof value === 'string' && value.toUpperCase().length > 1;
}

Try / catch

let hints;
try {
  hints = new FilterHints();
} catch (e) {
  if (e.message.includes('linkHintNumbers')) {
    Settings.set('linkHintNumbers', '0123456789');
    hints = new FilterHints();
  } else { throw e; }
}

Prevention

When it happens

Trigger: Constructing a FilterHints instance (activating link hints in filter/number mode) while Settings.get('linkHintNumbers').toUpperCase() has length <= 1 — e.g. the setting is '', '1', or a single digit/character.

Common situations: A user edits linkHintNumbers in the options page to a single digit like '9'; a settings JSON import or sync drops the default '0123456789' to a shorter value; tests stub Settings with a truncated value before instantiating FilterHints.

Related errors


AI-assisted analysis of philc/vimium@5aa29614bf (2026-08-30). Data as JSON: /api/errors/ee933647f702e63a. Report an issue: GitHub.