Skip to content

Commit 865bca3

Browse files
authored
Merge pull request #210 from sid-srini/vsc196-show-runConfig-workspace
[JAVAVSCODE #196] Run Configuration section is unavailable in the Explorer panel for non-workspace opened Java files
2 parents 22c2526 + 51b0597 commit 865bca3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

vscode/src/runConfiguration.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ import * as vscode from 'vscode';
2323
import { homedir } from 'os';
2424

2525
export async function initializeRunConfiguration(): Promise<boolean> {
26-
const java = await vscode.workspace.findFiles('**/*.java', '**/node_modules/**', 1);
27-
if (java?.length > 0) {
26+
if (vscode.workspace.name || vscode.workspace.workspaceFile) {
27+
const java = await vscode.workspace.findFiles('**/*.java', '**/node_modules/**', 1);
28+
if (java?.length > 0) {
2829
return true;
29-
}
30+
}
31+
} else {
32+
for (let doc of vscode.workspace.textDocuments) {
33+
if (doc.fileName?.endsWith(".java")) {
34+
return true;
35+
}
36+
}
37+
}
3038
return false;
3139
}
3240

@@ -152,7 +160,7 @@ class RunConfigurationNode extends vscode.TreeItem {
152160

153161
setValue(value: string | undefined) {
154162
this.value = value;
155-
this.getConfig().update(this.settingsKey, this.value, false);
163+
this.getConfig().update(this.settingsKey, this.value, vscode.workspace.name || vscode.workspace.workspaceFile ? null : true);
156164
this.updateNode();
157165
}
158166

@@ -192,7 +200,7 @@ const vmOptionsNode = new VMOptionsNode();
192200
class EnvironmentVariablesNode extends RunConfigurationNode {
193201

194202
constructor() {
195-
super('Environment:', 'Customize evironment variables', 'Example: var1=one, varTwo=2', 'env');
203+
super('Environment:', 'Customize environment variables', 'Example: var1=one, varTwo=2', 'env');
196204
}
197205

198206
}

0 commit comments

Comments
 (0)