()
| 822 | } |
| 823 | |
| 824 | export async function acceptFirstSuggestion(): Promise<void> { |
| 825 | // Ensure we are getting some results. This fixes a race where the server might've been |
| 826 | // starting up as the test got here. |
| 827 | const editor = currentEditor(); |
| 828 | const doc = editor.document; |
| 829 | const pos = editor.selection.end; |
| 830 | let results: vs.CompletionList | undefined; |
| 831 | let remainingTries = 10; |
| 832 | while (!results || results.isIncomplete || results.items.length === 0) { |
| 833 | await delay(50); |
| 834 | results = await vs.commands.executeCommand<vs.CompletionList>("vscode.executeCompletionItemProvider", doc.uri, pos, undefined, 1 /* resolveCount, forces resolve for the item */); |
| 835 | if (--remainingTries <= 0) |
| 836 | break; |
| 837 | } |
| 838 | |
| 839 | // TODO: Can we make this better (we're essentially waiting to ensure resolve completed |
| 840 | // before we accept, so that we don't insert the standard label without the extra |
| 841 | // edits which are added in in resolve). |
| 842 | await vs.commands.executeCommand("editor.action.triggerSuggest"); |
| 843 | await delay(100); |
| 844 | await waitForEditorChange(() => vs.commands.executeCommand("acceptSelectedSuggestion")); |
| 845 | await delay(100); |
| 846 | } |
| 847 | |
| 848 | export function ensureInsertReplaceRanges(range: undefined | vs.Range | { inserting: vs.Range, replacing: vs.Range }, insertRangeMatch: string, replaceRangeMatch: string) { |
| 849 | if (range && "inserting" in range && "replacing" in range) { |
no test coverage detected