Skip to content

Show hover cards when issue numbers are followed by , or . #2085

@StephanTLavavej

Description

@StephanTLavavej

This issue is similar to #1813, but not a duplicate.

  • Extension version: 0.19.0
  • VSCode Version: 1.48.1
  • OS: Windows_NT x64 10.0.19041

Steps to Reproduce:

  1. Hover over // GH-2085, blah blah.
  2. Result: no hover card 😿
  3. Hover over // Test GH-2085.
  4. Result: no hover card 😿

hover2

The regex mentioned in #1813 currently considers ($|[\s\:\;\-\(\=\)]) after an issue number:

export const ISSUE_EXPRESSION = /(([^\s]+)\/([^\s]+))?(#|GH-)([1-9][0-9]*)($|[\s\:\;\-\(\=\)])/;
export const ISSUE_OR_URL_EXPRESSION = /(https?:\/\/github\.com\/(([^\s]+)\/([^\s]+))\/([^\s]+\/)?(issues|pull)\/([0-9]+)(#issuecomment\-([0-9]+))?)|(([^\s]+)\/([^\s]+))?(#|GH-)([1-9][0-9]*)($|[\s\:\;\-\(\=\)])/;

Extending this to include , and . would be nice, but (as mentioned in #1813 (comment) ) it really seems like this should simply be looking for a word boundary with \b. That would allow hover cards to activate for comments like // Is this GH-2085?, // Avoid the problem mentioned in GH-2085!, /***Test GH-2085***/, etc.


As an aside, most characters in character classes lose their specialness and don't need to be escaped; r1 and r2 behave identically:

const r1 = /[\s\:\;\-\(\=\)]/;
const r2 = /[\s:;\-(=)]/;
for (const c of [' ', ':', ';', '-', '(', '=', ')', 'x']) {
  console.log(`'${c}': ${r1.test(c) === r2.test(c)}`);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions