Skip to content

Commit

Permalink
Remember the choice when asking project selection (#3428)
Browse files Browse the repository at this point in the history
- Remember the choice when asking project selection
- Update @vscode/test-electron to fix macos ci

Signed-off-by: Sheng Chen <[email protected]>
  • Loading branch information
jdneo authored Dec 14, 2023
1 parent 7ef38c6 commit 7bd5ded
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 169 deletions.
207 changes: 40 additions & 167 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@
"@types/vscode": "^1.77.0",
"@types/winreg": "^1.2.30",
"@types/winston": "^2.4.4",
"@vscode/test-electron": "^2.1.5",
"@vscode/test-electron": "^2.3.8",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"css-loader": "^6.7.3",
Expand Down
2 changes: 2 additions & 0 deletions src/buildFilesSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IBuildTool, getContributedBuildTools } from "./plugin";

export const PICKED_BUILD_FILES = "java.pickedBuildFiles";
export const BUILD_TOOL_FOR_CONFLICTS = "java.buildToolForConflicts";
export const IMPORT_METHOD = "java.importMethod";
export class BuildFileSelector {
/**
* The build tools that are contributed/supported by extensions.
Expand Down Expand Up @@ -295,4 +296,5 @@ interface IBuildFilePicker extends QuickPickItem {
export function cleanupProjectPickerCache(context: ExtensionContext) {
context.workspaceState.update(PICKED_BUILD_FILES, undefined);
context.workspaceState.update(BUILD_TOOL_FOR_CONFLICTS, undefined);
context.workspaceState.update(IMPORT_METHOD, undefined);
}
8 changes: 7 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cleanupLombokCache } from './lombokSupport';
import { ensureExists, getJavaConfiguration } from './utils';
import { apiManager } from './apiManager';
import { isActive, setActive, smartSemicolonDetection } from './smartSemicolonDetection';
import { BuildFileSelector, PICKED_BUILD_FILES } from './buildFilesSelector';
import { BuildFileSelector, IMPORT_METHOD, PICKED_BUILD_FILES } from './buildFilesSelector';

const DEFAULT_HIDDEN_FILES: string[] = ['**/.classpath', '**/.project', '**/.settings', '**/.factorypath'];
const IS_WORKSPACE_JDK_ALLOWED = "java.ls.isJdkAllowed";
Expand Down Expand Up @@ -370,6 +370,11 @@ export function handleTextDocumentChanges(document: TextDocument, changes: reado
export async function getImportMode(context: ExtensionContext, selector: BuildFileSelector): Promise<ImportMode> {
const mode = getJavaConfiguration().get<string>("import.projectSelection");
if (mode === "manual") {
// use automatic mode if user has selected "Import All" before.
if (context.workspaceState.get(IMPORT_METHOD) === "Import All") {
return ImportMode.automatic;
}

// if no selectable build files, use automatic mode
const hasBuildFiles = await selector.hasBuildFiles();
if (!hasBuildFiles) {
Expand All @@ -386,6 +391,7 @@ export async function getImportMode(context: ExtensionContext, selector: BuildFi
{ modal: true },
"Import All", "Let Me Select...");
if (answer === "Import All") {
context.workspaceState.update(IMPORT_METHOD, "Import All");
return ImportMode.automatic;
} else if (answer === "Let Me Select...") {
return ImportMode.manual;
Expand Down

0 comments on commit 7bd5ded

Please sign in to comment.