-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed crash on class member completions with auto imports from merged…
… ambient modules (#60340)
- Loading branch information
Showing
2 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/cases/fourslash/autoImportCompletionAmbientMergedModule1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @strict: true | ||
// @module: commonjs | ||
|
||
// @filename: /node_modules/@types/vscode/index.d.ts | ||
//// declare module "vscode" { | ||
//// export class Position { | ||
//// readonly line: number; | ||
//// readonly character: number; | ||
//// } | ||
//// } | ||
|
||
// @filename: src/motion.ts | ||
//// import { Position } from "vscode"; | ||
//// | ||
//// export abstract class MoveQuoteMatch { | ||
//// public override async execActionWithCount( | ||
//// position: Position, | ||
//// ): Promise<void> {} | ||
//// } | ||
//// | ||
//// declare module "vscode" { | ||
//// interface Position { | ||
//// toString(): string; | ||
//// } | ||
//// } | ||
|
||
// @filename: src/smartQuotes.ts | ||
//// import { MoveQuoteMatch } from "./motion"; | ||
//// | ||
//// export class MoveInsideNextQuote extends MoveQuoteMatch {/*1*/ | ||
//// keys = ["i", "n", "q"]; | ||
//// } | ||
|
||
const preferences = { | ||
includeCompletionsWithInsertText: true, | ||
includeCompletionsWithClassMemberSnippets: true, | ||
}; | ||
|
||
verify.completions({ | ||
marker: "1", | ||
includes: [ | ||
{ | ||
name: "execActionWithCount", | ||
insertText: "public execActionWithCount(position: Position): Promise<void> {\n}", | ||
filterText: "execActionWithCount", | ||
hasAction: true, | ||
source: "ClassMemberSnippet/", | ||
}, | ||
], | ||
preferences, | ||
isNewIdentifierLocation: true, | ||
}); | ||
|
||
verify.applyCodeActionFromCompletion("1", { | ||
name: "execActionWithCount", | ||
source: "ClassMemberSnippet/", | ||
description: `Includes imports of types referenced by 'execActionWithCount'`, | ||
newFileContent: `import { Position } from "vscode"; | ||
import { MoveQuoteMatch } from "./motion"; | ||
export class MoveInsideNextQuote extends MoveQuoteMatch { | ||
keys = ["i", "n", "q"]; | ||
}`, | ||
preferences, | ||
}); |