@@ -5,7 +5,7 @@ import { findChildContainingExactPosition } from '../src/utils'
55import handleCommand from '../src/specialCommands/handle'
66import _ from 'lodash'
77import { defaultConfigFunc , entrypoint , settingsOverride , sharedLanguageService } from './shared'
8- import { fileContentsSpecialPositions , fourslashLikeTester , getCompletionsAtPosition } from './testing'
8+ import { fileContentsSpecialPositions , fourslashLikeTester , getCompletionsAtPosition , overrideSettings } from './testing'
99import constructMethodSnippet from '../src/constructMethodSnippet'
1010
1111const { languageService, languageServiceHost, updateProject, getCurrentFile } = sharedLanguageService
@@ -150,33 +150,54 @@ describe('Method snippets', () => {
150150 } = {}, ...c): void
151151 }
152152 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*/
153164 ` )
154165
155166 compareMethodSnippetAgainstMarker ( markers , 1 , null )
156167 compareMethodSnippetAgainstMarker ( markers , 2 , '()' )
157168 compareMethodSnippetAgainstMarker ( markers , 3 , '(a)' )
158169 compareMethodSnippetAgainstMarker ( markers , 4 , '($b)' )
159170 compareMethodSnippetAgainstMarker ( markers , 5 , '(a, b, { d, e: {} }, ...c)' )
171+ compareMethodSnippetAgainstMarker ( markers , 6 , '(a, b, c)' )
160172 } )
161173
162174 test ( 'Insert text = always-declaration' , ( ) => {
163- settingsOverride [ 'methodSnippets.insertText' ] = 'always-declaration'
175+ overrideSettings ( {
176+ 'methodSnippets.insertText' : 'always-declaration' ,
177+ } )
164178 const [ , _ , markers ] = fileContentsSpecialPositions ( /* ts */ `
165179 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
170190 }
171191 baz/*1*/
172192 ` )
173193
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)' )
176195 } )
177196
178197 test ( 'methodSnippets.skip' , ( ) => {
179- settingsOverride [ 'methodSnippets.skip' ] = 'optional-and-rest'
198+ overrideSettings ( {
199+ 'methodSnippets.skip' : 'optional-and-rest' ,
200+ } )
180201 const [ , _ , markers ] = fileContentsSpecialPositions ( /* ts */ `
181202 declare const baz: {
182203 (a: string = "test", b?, {
@@ -327,7 +348,9 @@ test('Switch Case Exclude Covered', () => {
327348} )
328349
329350test ( 'Case-sensetive completions' , ( ) => {
330- settingsOverride . caseSensitiveCompletions = true
351+ overrideSettings ( {
352+ caseSensitiveCompletions : true ,
353+ } )
331354 const [ _positivePositions , _negativePositions , numPositions ] = fileContentsSpecialPositions ( /* ts */ `
332355 const a = {
333356 TestItem: 5,
@@ -348,7 +371,9 @@ test('Case-sensetive completions', () => {
348371} )
349372
350373test ( 'Fix properties sorting' , ( ) => {
351- settingsOverride . fixSuggestionsSorting = true
374+ overrideSettings ( {
375+ fixSuggestionsSorting : true ,
376+ } )
352377 const tester = fourslashLikeTester ( /* tsx */ `
353378 let a: {
354379 d
@@ -386,6 +411,9 @@ test('Fix properties sorting', () => {
386411// ts 5
387412test . todo ( 'Change to function kind' , ( ) => {
388413 settingsOverride [ 'experiments.changeKindToFunction' ] = true
414+ overrideSettings ( {
415+ 'experiments.changeKindToFunction' : true ,
416+ } )
389417 const tester = fourslashLikeTester ( /* ts */ `
390418 // declare const foo: boolean
391419 const foo = () => {}
@@ -579,37 +607,40 @@ test('In Keyword Completions', () => {
579607 "insertText": "a",
580608 "isSnippet": true,
581609 "kind": "string",
610+ "labelDetails": {
611+ "description": "2, 3",
612+ },
582613 "name": "a",
583- "sourceDisplay": [
584- {
585- "kind": "text",
586- "text": "2, 3",
587- },
588- ],
614+ "replacementSpan": {
615+ "length": 0,
616+ "start": 101,
617+ },
589618 },
590619 {
591620 "insertText": "b",
592621 "isSnippet": true,
593622 "kind": "string",
623+ "labelDetails": {
624+ "description": "2",
625+ },
594626 "name": "☆b",
595- "sourceDisplay": [
596- {
597- "kind": "text",
598- "text": "2",
599- },
600- ],
627+ "replacementSpan": {
628+ "length": 0,
629+ "start": 101,
630+ },
601631 },
602632 {
603633 "insertText": "c",
604634 "isSnippet": true,
605635 "kind": "string",
636+ "labelDetails": {
637+ "description": "3",
638+ },
606639 "name": "☆c",
607- "sourceDisplay": [
608- {
609- "kind": "text",
610- "text": "3",
611- },
612- ],
640+ "replacementSpan": {
641+ "length": 0,
642+ "start": 101,
643+ },
613644 },
614645 ],
615646 "prevCompletionsMap": {
0 commit comments