Skip to content

Commit

Permalink
fix: Failed to create test item when test controller is not initializ…
Browse files Browse the repository at this point in the history
…ed (#1270)
  • Loading branch information
jdneo authored Aug 9, 2021
1 parent bb2614f commit d117191
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const cp = require('child_process');
const tslint = require('gulp-tslint');
const path = require('path');
const fs = require('fs');
const os = require('os');

const serverDir = path.join(__dirname, 'java-extension');
const resourceDir = path.join(__dirname, 'resources');

// Build required jar files.
gulp.task('build-plugin', (done) => {
Expand Down Expand Up @@ -77,6 +77,7 @@ function updateVersion() {
});

fs.writeFileSync('./package.json', JSON.stringify(packageJsonData, null, 4));
fs.appendFileSync('./package.json', os.EOL);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
instrumentOperationAsVsCodeCommand(JavaTestRunnerCommands.DEBUG_TEST_FROM_JAVA_PROJECT_EXPLORER, async (node: any) => await runTestsFromJavaProjectExplorer(node, true /* isDebug */)),
window.onDidChangeActiveTextEditor(async (e: TextEditor | undefined) => {
if (e?.document) {
if (!isJavaFile(e.document)) {
if (!isJavaFile(e.document) || !isStandardServerReady()) {
return;
}

Expand All @@ -111,9 +111,10 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
}
}),
workspace.onDidChangeTextDocument(async (e: TextDocumentChangeEvent) => {
if (!isJavaFile(e.document)) {
if (!isJavaFile(e.document) || !isStandardServerReady()) {
return;
}

if (!await testSourceProvider.isOnTestSourcePath(e.document.uri)) {
return;
}
Expand All @@ -135,9 +136,9 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
if (isStandardServerReady()) {
registerTestCodeActionProvider();
createTestController();
await showTestItemsInCurrentFile();
}

await showTestItemsInCurrentFile();
}

async function showTestItemsInCurrentFile(): Promise<void> {
Expand Down

0 comments on commit d117191

Please sign in to comment.