File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,11 @@ export type Configuration = {
239
239
* @default true
240
240
*/
241
241
switchExcludeCoveredCases : boolean
242
+ /**
243
+ * Disable useless highlighting,
244
+ * @default disable
245
+ */
246
+ disableUselessHighlighting : 'disable' | 'inJsxArttributeStrings' | 'inAllStrings'
242
247
/**
243
248
* Improve JSX attribute completions:
244
249
* - 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'
17
17
import decorateReferences from './references'
18
18
import handleSpecialCommand from './specialCommands/handle'
19
19
import decorateDefinitions from './definitions'
20
+ import decorateDocumentHighlights from './documentHighlights'
20
21
21
22
const thisPluginMarker = Symbol ( '__essentialPluginsMarker__' )
22
23
@@ -148,6 +149,7 @@ export = ({ typescript }: { typescript: typeof ts }) => {
148
149
decorateSemanticDiagnostics ( proxy , info , c )
149
150
decorateDefinitions ( proxy , info , c )
150
151
decorateReferences ( proxy , info . languageService , c )
152
+ decorateDocumentHighlights ( proxy , info . languageService , c )
151
153
152
154
if ( ! __WEB__ ) {
153
155
// 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