@@ -5,7 +5,7 @@ import { findChildContainingExactPosition } from '../src/utils'
5
5
import handleCommand from '../src/specialCommands/handle'
6
6
import _ from 'lodash'
7
7
import { defaultConfigFunc , entrypoint , settingsOverride , sharedLanguageService } from './shared'
8
- import { fileContentsSpecialPositions , fourslashLikeTester , getCompletionsAtPosition } from './testing'
8
+ import { fileContentsSpecialPositions , fourslashLikeTester , getCompletionsAtPosition , overrideSettings } from './testing'
9
9
import constructMethodSnippet from '../src/constructMethodSnippet'
10
10
11
11
const { languageService, languageServiceHost, updateProject, getCurrentFile } = sharedLanguageService
@@ -150,33 +150,54 @@ describe('Method snippets', () => {
150
150
} = {}, ...c): void
151
151
}
152
152
baz/*5*/
153
+
154
+ // should ignores comments
155
+ declare const withComments = (
156
+ a: boolean,
157
+ // comment
158
+ b: boolean,
159
+ /* jsdoc */
160
+ c: boolean
161
+ ) => void
162
+
163
+ withComments/*6*/
153
164
` )
154
165
155
166
compareMethodSnippetAgainstMarker ( markers , 1 , null )
156
167
compareMethodSnippetAgainstMarker ( markers , 2 , '()' )
157
168
compareMethodSnippetAgainstMarker ( markers , 3 , '(a)' )
158
169
compareMethodSnippetAgainstMarker ( markers , 4 , '($b)' )
159
170
compareMethodSnippetAgainstMarker ( markers , 5 , '(a, b, { d, e: {} }, ...c)' )
171
+ compareMethodSnippetAgainstMarker ( markers , 6 , '(a, b, c)' )
160
172
} )
161
173
162
174
test ( 'Insert text = always-declaration' , ( ) => {
163
- settingsOverride [ 'methodSnippets.insertText' ] = 'always-declaration'
175
+ overrideSettings ( {
176
+ 'methodSnippets.insertText' : 'always-declaration' ,
177
+ } )
164
178
const [ , _ , markers ] = fileContentsSpecialPositions ( /* ts */ `
165
179
declare const baz: {
166
- (a: string = "test", b?, {
167
- d = false,
168
- e: {}
169
- } = { }, ...c): void
180
+ (
181
+ a: string =
182
+ "super" +
183
+ "test",
184
+ b?, {
185
+ d = false,
186
+ e: {}
187
+ } = { },
188
+ ...c
189
+ ): void
170
190
}
171
191
baz/*1*/
172
192
` )
173
193
174
- compareMethodSnippetAgainstMarker ( markers , 1 , '(a = "test", b?, { d = false, e: {} } = {}, ...c)' )
175
- settingsOverride [ 'methodSnippets.insertText' ] = 'binding-name'
194
+ compareMethodSnippetAgainstMarker ( markers , 1 , '(a = "super" + "test", b?, { d = false, e: {} } = {}, ...c)' )
176
195
} )
177
196
178
197
test ( 'methodSnippets.skip' , ( ) => {
179
- settingsOverride [ 'methodSnippets.skip' ] = 'optional-and-rest'
198
+ overrideSettings ( {
199
+ 'methodSnippets.skip' : 'optional-and-rest' ,
200
+ } )
180
201
const [ , _ , markers ] = fileContentsSpecialPositions ( /* ts */ `
181
202
declare const baz: {
182
203
(a: string = "test", b?, {
@@ -327,7 +348,9 @@ test('Switch Case Exclude Covered', () => {
327
348
} )
328
349
329
350
test ( 'Case-sensetive completions' , ( ) => {
330
- settingsOverride . caseSensitiveCompletions = true
351
+ overrideSettings ( {
352
+ caseSensitiveCompletions : true ,
353
+ } )
331
354
const [ _positivePositions , _negativePositions , numPositions ] = fileContentsSpecialPositions ( /* ts */ `
332
355
const a = {
333
356
TestItem: 5,
@@ -348,7 +371,9 @@ test('Case-sensetive completions', () => {
348
371
} )
349
372
350
373
test ( 'Fix properties sorting' , ( ) => {
351
- settingsOverride . fixSuggestionsSorting = true
374
+ overrideSettings ( {
375
+ fixSuggestionsSorting : true ,
376
+ } )
352
377
const tester = fourslashLikeTester ( /* tsx */ `
353
378
let a: {
354
379
d
@@ -386,6 +411,9 @@ test('Fix properties sorting', () => {
386
411
// ts 5
387
412
test . todo ( 'Change to function kind' , ( ) => {
388
413
settingsOverride [ 'experiments.changeKindToFunction' ] = true
414
+ overrideSettings ( {
415
+ 'experiments.changeKindToFunction' : true ,
416
+ } )
389
417
const tester = fourslashLikeTester ( /* ts */ `
390
418
// declare const foo: boolean
391
419
const foo = () => {}
@@ -579,37 +607,40 @@ test('In Keyword Completions', () => {
579
607
"insertText": "a",
580
608
"isSnippet": true,
581
609
"kind": "string",
610
+ "labelDetails": {
611
+ "description": "2, 3",
612
+ },
582
613
"name": "a",
583
- "sourceDisplay": [
584
- {
585
- "kind": "text",
586
- "text": "2, 3",
587
- },
588
- ],
614
+ "replacementSpan": {
615
+ "length": 0,
616
+ "start": 101,
617
+ },
589
618
},
590
619
{
591
620
"insertText": "b",
592
621
"isSnippet": true,
593
622
"kind": "string",
623
+ "labelDetails": {
624
+ "description": "2",
625
+ },
594
626
"name": "☆b",
595
- "sourceDisplay": [
596
- {
597
- "kind": "text",
598
- "text": "2",
599
- },
600
- ],
627
+ "replacementSpan": {
628
+ "length": 0,
629
+ "start": 101,
630
+ },
601
631
},
602
632
{
603
633
"insertText": "c",
604
634
"isSnippet": true,
605
635
"kind": "string",
636
+ "labelDetails": {
637
+ "description": "3",
638
+ },
606
639
"name": "☆c",
607
- "sourceDisplay": [
608
- {
609
- "kind": "text",
610
- "text": "3",
611
- },
612
- ],
640
+ "replacementSpan": {
641
+ "length": 0,
642
+ "start": 101,
643
+ },
613
644
},
614
645
],
615
646
"prevCompletionsMap": {
0 commit comments