File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,6 +239,11 @@ export type Configuration = {
239239 * @default true
240240 */
241241 switchExcludeCoveredCases : boolean
242+ /**
243+ * Disable useless highlighting,
244+ * @default disable
245+ */
246+ disableUselessHighlighting : 'disable' | 'inJsxArttributeStrings' | 'inAllStrings'
242247 /**
243248 * Improve JSX attribute completions:
244249 * - enable builtin jsx attribute completion fix
Original file line number Diff line number Diff line change 1+ import { GetConfig } from './types'
2+ import { findChildContainingPosition } from './utils'
3+
4+ export default ( proxy : ts . LanguageService , languageService : ts . LanguageService , c : GetConfig ) => {
5+ proxy . getDocumentHighlights = ( fileName , position , filesToSearch ) => {
6+ const prior = languageService . getDocumentHighlights ( fileName , position , filesToSearch )
7+ if ( ! prior ) return
8+ if ( prior . length !== 1 ) return prior
9+ const node = findChildContainingPosition ( ts , languageService . getProgram ( ) ! . getSourceFile ( fileName ) ! , position )
10+ if ( ! node ) return prior
11+ if ( c ( 'disableUselessHighlighting' ) !== 'disable' ) {
12+ if ( ts . isStringLiteralLike ( node ) ) {
13+ if ( c ( 'disableUselessHighlighting' ) === 'inAllStrings' ) return
14+ else if ( ts . isJsxAttribute ( node . parent ) ) return
15+ }
16+ }
17+ return prior
18+ }
19+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import decorateCodeFixes from './codeFixes'
1717import decorateReferences from './references'
1818import handleSpecialCommand from './specialCommands/handle'
1919import decorateDefinitions from './definitions'
20+ import decorateDocumentHighlights from './documentHighlights'
2021
2122const thisPluginMarker = Symbol ( '__essentialPluginsMarker__' )
2223
@@ -148,6 +149,7 @@ export = ({ typescript }: { typescript: typeof ts }) => {
148149 decorateSemanticDiagnostics ( proxy , info , c )
149150 decorateDefinitions ( proxy , info , c )
150151 decorateReferences ( proxy , info . languageService , c )
152+ decorateDocumentHighlights ( proxy , info . languageService , c )
151153
152154 if ( ! __WEB__ ) {
153155 // dedicated syntax server (which is enabled by default), which fires navtree doesn't seem to receive onConfigurationChanged
You can’t perform that action at this time.
0 commit comments