Skip to content

Commit cf26b9b

Browse files
jdneorgrunber
authored andcommitted
Do not show the import notification when no projects available
Signed-off-by: Sheng Chen <[email protected]>
1 parent c86f4f4 commit cf26b9b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/serverTaskPresenter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { tasks, Task, TaskScope, Pseudoterminal, CustomExecution, TaskExecution, TaskRevealKind, TaskPanelKind, EventEmitter, Event, TerminalDimensions, window, ProgressLocation, Progress } from "vscode";
1+
import { tasks, Task, TaskScope, Pseudoterminal, CustomExecution, TaskExecution, TaskRevealKind, TaskPanelKind, EventEmitter, Event, TerminalDimensions, window, ProgressLocation, Progress, workspace } from "vscode";
22
import { serverTasks } from "./serverTasks";
33
import { Disposable } from "vscode-languageclient";
44
import { ProgressReport } from "./protocol";
@@ -119,9 +119,11 @@ export class ActivationProgressNotification {
119119
private hideEmitter = new EventEmitter<void>();
120120
private onHide = this.hideEmitter.event;
121121
private disposables: Disposable[] = [];
122-
private lastJobId: string;
123122

124123
public showProgress() {
124+
if (!workspace.workspaceFolders) {
125+
return;
126+
}
125127
const showBuildStatusEnabled = getJavaConfiguration().get("showBuildStatusOnStart.enabled");
126128
if (typeof showBuildStatusEnabled === "string" || showBuildStatusEnabled instanceof String) {
127129
if (showBuildStatusEnabled !== "notification") {

src/standardLanguageClient.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,14 @@ export class StandardLanguageClient {
446446
}
447447
}
448448

449-
function showImportFinishNotification(context: ExtensionContext) {
450-
const showNotification: boolean | undefined = context.globalState.get<boolean>("java.neverShowImportFinishNotification");
451-
if (!showNotification) {
449+
async function showImportFinishNotification(context: ExtensionContext) {
450+
const neverShow: boolean | undefined = context.globalState.get<boolean>("java.neverShowImportFinishNotification");
451+
if (!neverShow) {
452+
const projectUris: string[] = await commands.executeCommand<string[]>(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.GET_ALL_JAVA_PROJECTS);
453+
if (projectUris.length === 0 || (projectUris.length === 1 && projectUris[0].includes("jdt.ls-java-project"))) {
454+
return;
455+
}
456+
452457
const options = ["Don't show again"];
453458
if (extensions.getExtension("vscjava.vscode-java-dependency")) {
454459
options.unshift("View projects");

0 commit comments

Comments
 (0)