Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remember the choice when asking project selection #3428

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update here is to fix the ci failure on macos: microsoft/vscode-test#246 (comment)

"@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
Loading