add the waiting for the promise

This commit is contained in:
Akshita 2019-03-21 11:30:43 -07:00
Родитель 3f5d5ce075
Коммит 0d61bd6546
2 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -141,12 +141,13 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
coreClrDebugPromise = coreclrdebug.activate(extension, context, platformInfo, eventStream);
}
let razorPromise = Promise.resolve();
if (!optionProvider.GetLatestOptions().razorDisabled) {
const razorObserver = new RazorLoggerObserver(omnisharpChannel);
eventStream.subscribe(razorObserver.post);
if (!optionProvider.GetLatestOptions().razorDevMode) {
await activateRazorExtension(context, extension.extensionPath, eventStream);
razorPromise = activateRazorExtension(context, extension.extensionPath, eventStream);
}
}
@ -155,6 +156,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
let langService = await langServicePromise;
await langService.server.waitForEmptyEventQueue();
await coreClrDebugPromise;
await razorPromise;
},
getAdvisor: async () => {
let langService = await langServicePromise;

Просмотреть файл

@ -7,7 +7,7 @@ import * as assert from 'assert';
import * as path from 'path';
import * as vscode from 'vscode';
import testAssetWorkspace from '../integrationTests/testAssets/testAssetWorkspace';
import { activateCSharpExtension, pollUntil, waitForDocumentUpdate, htmlLanguageFeaturesExtensionReady, extensionActivated } from '../integrationTests/integrationHelpers';
import { activateCSharpExtension, pollUntil, waitForDocumentUpdate, htmlLanguageFeaturesExtensionReady } from '../integrationTests/integrationHelpers';
let doc: vscode.TextDocument;
let editor: vscode.TextEditor;
@ -23,7 +23,7 @@ suite(`Completions ${testAssetWorkspace.description}`, () => {
const filePath = path.join(testAssetWorkspace.projects[0].projectDirectoryPath, 'Pages', 'Index.cshtml');
doc = await vscode.workspace.openTextDocument(filePath);
editor = await vscode.window.showTextDocument(doc);
await extensionActivated;
await activateCSharpExtension();
});
teardown(async () => {
@ -35,6 +35,25 @@ suite(`Completions ${testAssetWorkspace.description}`, () => {
await testAssetWorkspace.cleanupWorkspace();
});
test('Can get HTML completions on document open', async () => {
// This test relies on the Index.cshtml document containing at least 1 HTML tag in it.
// For the purposes of this test it locates that tag and tries to get the Html completion
// list from it.
const content = doc.getText();
const tagNameIndex = content.indexOf('<') + 1;
const docPosition = doc.positionAt(tagNameIndex);
const completions = await vscode.commands.executeCommand<vscode.CompletionList>(
'vscode.executeCompletionItemProvider',
doc.uri,
docPosition);
const matchingCompletions = completions!.items
.filter(item => (typeof item.insertText === 'string') && item.insertText === 'iframe')
.map(item => item.insertText as string);
assert.deepEqual(matchingCompletions, ['iframe']);
});
test('Can complete C# code blocks', async () => {
const lastLine = new vscode.Position(doc.lineCount - 1, 0);
await editor.edit(edit => edit.insert(lastLine, '@{}'));