{"record":{"id":"ee933647f702e63a","repo":"philc/vimium","slug":"the-linkhintnumbers-setting-must-have-more-than-1","errorCode":null,"errorMessage":"The linkHintNumbers setting must have more than 1 character.","messagePattern":"The linkHintNumbers setting must have more than 1 character\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"content_scripts/link_hints.js","lineNumber":930,"sourceCode":"\n  popKeyChar() {\n    return this.hintKeystrokeQueue.pop();\n  }\n\n  // For alphabet hints, <Space> always rotates the hints, regardless of modifiers.\n  shouldRotateHints() {\n    return true;\n  }\n}\n\n// Use characters for hints, and also filter links by their text.\nclass FilterHints {\n  constructor() {\n    this.linkHintNumbers = Settings.get(\"linkHintNumbers\").toUpperCase();\n    // Ensure we have more than 1 character to generate hint strings. With 1 character, every hint\n    // will be another hint's prefix (\"1\", \"11\", ...).\n    if (this.linkHintNumbers.length <= 1) {\n      throw new Error(\"The linkHintNumbers setting must have more than 1 character.\");\n    }\n\n    this.hintKeystrokeQueue = [];\n    this.linkTextKeystrokeQueue = [];\n    this.activeHintMarker = null;\n    // The regexp for splitting typed text and link texts. We split on sequences of non-word\n    // characters and link-hint numbers.\n    this.splitRegexp = new RegExp(\n      `[\\\\W${Utils.escapeRegexSpecialCharacters(this.linkHintNumbers)}]+`,\n    );\n  }\n\n  generateHintString(linkHintNumber) {\n    const base = this.linkHintNumbers.length;\n    const hint = [];\n    while (linkHintNumber > 0) {\n      hint.push(this.linkHintNumbers[Math.floor(linkHintNumber % base)]);\n      linkHintNumber = Math.floor(linkHintNumber / base);","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/philc/vimium/blob/5aa29614bf1dce05e0d316f8c38722e17f9b38c3/content_scripts/link_hints.js#L912-L948","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set linkHintNumbers in the extension options to at least 2 characters (default is '0123456789').","If the setting was corrupted by import/sync, reset hint settings to defaults.","In code/tests, verify Settings.get('linkHintNumbers').length > 1 before creating FilterHints.","Catch the error and fall back to the default numeric character set."],"exampleFix":"// before\nSettings.set('linkHintNumbers', '1');\nnew FilterHints(); // throws\n\n// after\nSettings.set('linkHintNumbers', '0123456789');\nnew FilterHints(); // ok","handlingStrategy":"validation","validationCode":"const nums = (Settings.get('linkHintNumbers') || '').toUpperCase();\nif (typeof nums !== 'string' || nums.length <= 1) {\n  throw new Error('linkHintNumbers must contain at least 2 characters');\n}","typeGuard":"function hasValidHintNumbers(value) {\n  return typeof value === 'string' && value.toUpperCase().length > 1;\n}","tryCatchPattern":"let hints;\ntry {\n  hints = new FilterHints();\n} catch (e) {\n  if (e.message.includes('linkHintNumbers')) {\n    Settings.set('linkHintNumbers', '0123456789');\n    hints = new FilterHints();\n  } else { throw e; }\n}","preventionTips":["Never persist linkHintNumbers shorter than 2 characters; validate on options-page save.","Sanitize imported/synced settings before writing them to the settings store.","Add a unit test constructing FilterHints with default settings.","Coerce and check the stored value (non-empty string, length > 1) before use."],"tags":["configuration","validation","browser-extension"],"backgroundTag":"invalid-setting-value","analyzedSha":"5aa29614bf1dce05e0d316f8c38722e17f9b38c3","analyzedAt":"2026-08-30T03:46:46.119Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}