Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix(app): keep used settings profiles in a scrollable picker (#2425)

l0ng-ai8961f6dbf4dc
diff --git a/crates/ide-host/src/plugins/intellij.rs b/crates/ide-host/src/plugins/intellij.rs
index 4ca022a6e..ade859c4d 100644
--- a/crates/ide-host/src/plugins/intellij.rs
+++ b/crates/ide-host/src/plugins/intellij.rs
@@ -78,7 +78,7 @@ pub fn read_source(path: &Path) -> IdeResult<IntellijThemeSource> {
/// The theme plugins of the JetBrains IDEs (and Android Studio) of this user,
/// the themes their IDEs are set to first.
pub fn installed_themes() -> Vec<InstalledIntellijTheme> {
- find_installed(&local_ide_dirs())
+ find_installed(&latest_product_versions(local_ide_dirs()))
}
/// The settings folder of a JetBrains IDE (or Android Studio) of this user.
@@ -91,7 +91,7 @@ pub struct InstalledIdeSettings {
pub path: IpcPath,
}
-/// The settings folders of the JetBrains IDEs of this user, newest first, one per product.
+/// The settings folders of the JetBrains IDEs of this user, most recently used first.
pub fn installed_ide_settings() -> Vec<InstalledIdeSettings> {
settings_folders(&local_ide_dirs())
}
@@ -108,14 +108,64 @@ fn local_ide_dirs() -> Vec<IdeDir> {
ide_dirs(layout, &home, |key| std::env::var_os(key))
}
-/// An IDE that was installed but never run has no `options/` yet: nothing to import.
fn settings_folders(ides: &[IdeDir]) -> Vec<InstalledIdeSettings> {
- ides.iter()
- .filter(|ide| ide.config.join("options").is_dir())
- .map(|ide| InstalledIdeSettings { ide: ide.label.clone(), path: ide.config.clone().into() })
+ let mut used: Vec<_> =
+ ides.iter().filter_map(|ide| settings_modified(&ide.config).map(|time| (ide, time))).collect();
+ used.sort_by(|(a, at), (b, bt)| {
+ bt.cmp(at).then_with(|| a.label.cmp(&b.label)).then_with(|| a.config.cmp(&b.config))
+ });
+ used.into_iter()
+ .map(|(ide, _)| InstalledIdeSettings { ide: ide.label.clone(), path: ide.config.clone().into() })
.collect()
}
+fn settings_modified(config: &Path) -> Option<std::time::SystemTime> {
+ let options = config.join("options");
+ // Match the folder reader: never count links or walk below the settings directories.
+ if !config.symlink_metadata().ok()?.is_dir() || !options.symlink_metadata().ok()?.is_dir() {
+ return None;
+ }
+ let mut modified = None;
+ let mut customised = false;
+ for entry in std::fs::read_dir(&options).ok()?.flatten() {
+ let path = entry.path();
+ if !entry.file_type().is_ok_and(|t| t.is_file())
+ || !path.extension().is_some_and(|e| e.eq_ignore_ascii_case("xml"))
+ {
+ continue;
+ }
+ let Ok(meta) = entry.metadata() else { continue };
+ modified = modified.max(meta.modified().ok());
+ // Startup bookkeeping can exist before the user has changed any settings.
+ let name = entry.file_name();
+ customised |= meta.len() > 0
+ && !matches!(
+ name.to_str(),
+ Some(
+ "other.xml"
+ | "nonRoamable.xml"
+ | "early-access-registry.xml"
+ | "applicationInfo.xml"
+ | "updates.xml"
+ | "usage.statistics.xml"
+ )
+ );
+ }
+ customised |= ["keymaps", "codestyles", "colors", "templates", "inspection"].iter().any(|sub| {
+ let dir = config.join(sub);
+ dir.symlink_metadata().is_ok_and(|m| m.is_dir())
+ && std::fs::read_dir(dir).into_iter().flatten().flatten().any(|entry| {
+ entry.file_type().is_ok_and(|t| t.is_file())
+ && entry.metadata().is_ok_and(|m| m.len() > 0)
+ && entry
+ .path()
+ .extension()
+ .is_some_and(|e| e.eq_ignore_ascii_case("xml") || e.eq_ignore_ascii_case("icls"))
+ })
+ });
+ customised.then(|| modified.or_else(|| options.metadata().ok()?.modified().ok()).unwrap_or(std::time::UNIX_EPOCH))
+}
+
fn read(path: &Path) -> Result<IntellijThemeSource, String> {
if path.extension().is_some_and(|e| e.eq_ignore_ascii_case("json")) {
return loose_theme(path);
@@ -449,8 +499,7 @@ struct IdeDir {
plugins: PathBuf,
}
-/// The settings folders of JetBrains IDEs and Android Studio (2020.1 and later), newest first, one
-/// per product: its newest version's (an upgrade leaves the older ones behind).
+/// The settings folders of JetBrains IDEs and Android Studio (2020.1 and later), newest version first.
fn ide_dirs(layout: Layout, home: &Path, env: impl Fn(&str) -> Option<OsString>) -> Vec<IdeDir> {
let var = |key: &str| env(key).filter(|v| !v.is_empty()).map(PathBuf::from);
let (config_root, data_root) = match layout {
@@ -490,11 +539,16 @@ fn ide_dirs(layout: Layout, home: &Path, env: impl Fn(&str) -> Option<OsString>)
}
}
out.sort_by(|a, b| b.version.cmp(&a.version).then_with(|| a.label.cmp(&b.label)));
- let mut products = std::collections::HashSet::new();
- out.retain(|ide| products.insert(ide.product.clone()));
out
}
+/// Theme discovery only uses the newest version of each product.
+fn latest_product_versions(mut ides: Vec<IdeDir>) -> Vec<IdeDir> {
+ let mut products = std::collections::HashSet::new();
+ ides.retain(|ide| products.insert(ide.product.clone()));
+ ides
+}
+
/// `IntelliJIdea2025.2` → (`IntelliJIdea`, (2025, 2), `2025.2`).
fn product_dir(name: &str) -> Option<(&str, (u32, u32), &str)> {
let at = name.find(|c: char| c.is_ascii_digit())?;
@@ -814,15 +868,16 @@ mod tests {
};
let mac = mk(home.join("Library/Application Support/JetBrains/IntelliJIdea2025.2"));
mk(home.join("Library/Application Support/JetBrains/Toolbox"));
- // An upgrade leaves the older version's folder behind: only the newest of a product counts.
+ // Settings import keeps every version; theme discovery uses only the newest.
mk(home.join("Library/Application Support/JetBrains/IntelliJIdea2024.3"));
mk(home.join("Library/Application Support/JetBrains/IntelliJIdea2025.10"));
let dirs = ide_dirs(Layout::Mac, home, |_| None);
- assert_eq!(dirs.len(), 1);
+ assert_eq!(dirs.len(), 3);
assert_eq!(dirs[0].label, "IntelliJ IDEA 2025.10");
+ assert_eq!(latest_product_versions(dirs).len(), 1);
std::fs::remove_dir(home.join("Library/Application Support/JetBrains/IntelliJIdea2025.10")).unwrap();
let dirs = ide_dirs(Layout::Mac, home, |_| None);
- assert_eq!(dirs.len(), 1);
+ assert_eq!(dirs.len(), 2);
assert_eq!(dirs[0].label, "IntelliJ IDEA 2025.2");
assert_eq!((dirs[0].config.clone(), dirs[0].plugins.clone()), (mac.clone(), mac.join("plugins")));
@@ -909,6 +964,90 @@ mod tests {
assert!(find_installed(&[]).is_empty());
}
+ #[test]
+ fn unused_newer_versions_do_not_hide_settings() {
+ let tmp = tempfile::tempdir().unwrap();
+ for (layout, root) in [
+ (Layout::Mac, "Library/Application Support"),
+ (Layout::Windows, "AppData/Roaming"),
+ (Layout::Xdg, ".config"),
+ ] {
+ let root = tmp.path().join(root).join("JetBrains");
+ let used = root.join("IntelliJIdea2024.3");
+ let fresh = root.join("IntelliJIdea2025.2");
+ write(&used.join("options/editor.xml"), b"<application><component name=\"EditorSettings\"/></application>");
+ std::fs::create_dir_all(&fresh).unwrap();
+ let expected = vec![InstalledIdeSettings { ide: "IntelliJ IDEA 2024.3".into(), path: used.into() }];
+ assert_eq!(settings_folders(&ide_dirs(layout, tmp.path(), |_| None)), expected);
+ write(&fresh.join("options/other.xml"), b"<application/>");
+ write(&fresh.join("options/early-access-registry.xml"), b"<application/>");
+ assert_eq!(settings_folders(&ide_dirs(layout, tmp.path(), |_| None)), expected);
+ }
+ }
+
+ #[test]
+ fn settings_candidates_keep_used_versions_and_sort_by_options_modification() {
+ let tmp = tempfile::tempdir().unwrap();
+ let root = tmp.path().join("Library/Application Support/JetBrains");
+ let put = |product: &str, file: &str, seconds| {
+ let path = root.join(product).join(file);
+ write(&path, b"<application/>");
+ std::fs::File::open(path)
+ .unwrap()
+ .set_modified(std::time::UNIX_EPOCH + std::time::Duration::from_secs(seconds))
+ .unwrap();
+ };
+ put("IntelliJIdea2025.2", "options/editor.xml", 100);
+ put("IntelliJIdea2024.3", "options/editor.xml", 200);
+ put("IntelliJIdea2024.3", "options/editor-font.xml", 400);
+ put("PyCharm2025.1", "options/editor.xml", 300);
+ // Directory times and unrelated files do not change options-file ordering.
+ write(&root.join("IntelliJIdea2025.2/options/README.txt"), b"recent");
+ let dirs = ide_dirs(Layout::Mac, tmp.path(), |_| None);
+ let found = settings_folders(&dirs);
+ assert_eq!(
+ found.iter().map(|s| s.ide.as_str()).collect::<Vec<_>>(),
+ ["IntelliJ IDEA 2024.3", "PyCharm 2025.1", "IntelliJ IDEA 2025.2"]
+ );
+ assert_eq!(found[0].path, root.join("IntelliJIdea2024.3"));
+ assert_eq!(latest_product_versions(dirs).len(), 2);
+ }
+
+ #[test]
+ fn skips_empty_and_startup_only_settings_but_keeps_custom_schemes() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = tmp.path();
+ assert!(settings_modified(config).is_none());
+ std::fs::create_dir(config.join("options")).unwrap();
+ assert!(settings_modified(config).is_none());
+ for file in ["other", "nonRoamable", "early-access-registry", "applicationInfo", "updates", "usage.statistics"]
+ {
+ write(
+ &config.join(format!("options/{file}.xml")),
+ b"<application><component name=\"Startup\"/></application>",
+ );
+ }
+ write(&config.join("options/editor.xml"), b"");
+ write(&config.join("options/nested/editor.xml"), b"<application/>");
+ for sub in ["keymaps", "codestyles", "colors", "templates", "inspection"] {
+ std::fs::create_dir(config.join(sub)).unwrap();
+ write(&config.join(sub).join("README.txt"), b"not settings");
+ }
+ assert!(settings_modified(config).is_none());
+ for (sub, file) in [
+ ("keymaps", "custom.xml"),
+ ("codestyles", "custom.xml"),
+ ("colors", "custom.icls"),
+ ("templates", "custom.xml"),
+ ("inspection", "custom.xml"),
+ ] {
+ let path = config.join(sub).join(file);
+ write(&path, b"<custom/>");
+ assert!(settings_modified(config).is_some(), "{sub} is a user setting");
+ std::fs::remove_file(path).unwrap();
+ }
+ }
+
#[test]
fn lists_the_settings_folders_of_ides_that_have_been_run() {
let tmp = tempfile::tempdir().unwrap();
diff --git a/src/features/app/__tests__/importFromJetBrainsIde.test.ts b/src/features/app/__tests__/importFromJetBrainsIde.test.ts
deleted file mode 100644
index a1cc5e3fd..000000000
--- a/src/features/app/__tests__/importFromJetBrainsIde.test.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-const listIdes = vi.fn();
-const ask = vi.fn();
-const importJetBrainsSettings = vi.fn();
-const notify = vi.fn();
-
-vi.mock("@/platform/ipc", async (original) => ({
- ...(await original<typeof import("@/platform/ipc")>()),
- call: <T>(result: Promise<T>) => result,
- commands: { settingsListJetbrainsIdes: () => listIdes() },
-}));
-vi.mock("@/workbench/messages", async (original) => ({
- ...(await original<typeof import("@/workbench/messages")>()),
- ask: (request: unknown) => ask(request),
-}));
-vi.mock("../jetbrainsSettings", () => ({ importJetBrainsSettings: (path: string) => importJetBrainsSettings(path) }));
-vi.mock("@/workbench/contributions", async (original) => ({
- ...(await original<typeof import("@/workbench/contributions")>()),
- notifications: () => ({ notify }),
-}));
-
-const { importFromJetBrainsIde } = await import("../projectActions");
-
-const idea = {
- ide: "IntelliJ IDEA 2025.2",
- path: "/Users/me/Library/Application Support/JetBrains/IntelliJIdea2025.2",
-};
-const studio = {
- ide: "Android Studio 2024.3",
- path: "/Users/me/Library/Application Support/Google/AndroidStudio2024.3",
-};
-
-beforeEach(() => {
- vi.clearAllMocks();
-});
-
-describe("Manage IDE Settings › Import Settings from JetBrains IDE…", () => {
- it("offers each installed IDE and imports the folder of the one chosen", async () => {
- listIdes.mockResolvedValue([idea, studio]);
- ask.mockResolvedValue({ button: "1" });
- await importFromJetBrainsIde();
- const request = ask.mock.calls[0]![0] as { buttons: { id: string; label: string; primary?: boolean }[] };
- expect(request.buttons).toEqual([
- { id: "0", label: "IntelliJ IDEA 2025.2", primary: true },
- { id: "1", label: "Android Studio 2024.3", primary: false },
- ]);
- expect(importJetBrainsSettings).toHaveBeenCalledExactlyOnceWith(studio.path);
- });
-
- it("imports nothing when the dialog is cancelled", async () => {
- listIdes.mockResolvedValue([idea]);
- ask.mockResolvedValue({ button: "cancel" });
- await importFromJetBrainsIde();
- expect(importJetBrainsSettings).not.toHaveBeenCalled();
- expect(notify).not.toHaveBeenCalled();
- });
-
- it("says so, without a dialog, when no JetBrains IDE has settings on this computer", async () => {
- listIdes.mockResolvedValue([]);
- await importFromJetBrainsIde();
- expect(ask).not.toHaveBeenCalled();
- expect(notify).toHaveBeenCalledWith(
- expect.objectContaining({ level: "warning", title: "No JetBrains IDE settings were found on this computer" }),
- );
- });
-
- it("reports a failure to list or read the folders", async () => {
- listIdes.mockRejectedValue(new Error("denied"));
- await importFromJetBrainsIde();
- expect(notify).toHaveBeenCalledWith(expect.objectContaining({ level: "error", title: "Cannot import settings" }));
- });
-});
diff --git a/src/features/app/__tests__/importFromJetBrainsIde.test.tsx b/src/features/app/__tests__/importFromJetBrainsIde.test.tsx
new file mode 100644
index 000000000..00311d4da
--- /dev/null
+++ b/src/features/app/__tests__/importFromJetBrainsIde.test.tsx
@@ -0,0 +1,112 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { act, fireEvent, render, screen } from "@testing-library/react";
+import { InputDialogsHost } from "@/workbench/inputDialogs";
+import pickerStyles from "@/workbench/inputDialogs.module.css";
+import listStyles from "@/ui/List.module.css";
+
+const listIdes = vi.fn();
+const importJetBrainsSettings = vi.fn();
+const notify = vi.fn();
+
+vi.mock("@/platform/ipc", async (original) => ({
+ ...(await original<typeof import("@/platform/ipc")>()),
+ call: <T,>(result: Promise<T>) => result,
+ commands: { settingsListJetbrainsIdes: () => listIdes() },
+}));
+vi.mock("../jetbrainsSettings", () => ({ importJetBrainsSettings: (path: string) => importJetBrainsSettings(path) }));
+vi.mock("@/workbench/contributions", async (original) => ({
+ ...(await original<typeof import("@/workbench/contributions")>()),
+ notifications: () => ({ notify }),
+}));
+
+const { importFromJetBrainsIde } = await import("../projectActions");
+
+const idea = {
+ ide: "IntelliJ IDEA 2025.2",
+ path: "/Users/me/Library/Application Support/JetBrains/IntelliJIdea2025.2",
+};
+const studio = {
+ ide: "Android Studio 2024.3",
+ path: "/Users/me/Library/Application Support/Google/AndroidStudio2024.3",
+};
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ render(<InputDialogsHost />);
+});
+
+describe("Manage IDE Settings › Import Settings from JetBrains IDE…", () => {
+ it("offers each installed IDE and imports the folder of the one chosen", async () => {
+ listIdes.mockResolvedValue([idea, studio]);
+ let done!: Promise<void>;
+ await act(async () => {
+ done = importFromJetBrainsIde();
+ });
+ const list = screen.getByRole("listbox", { name: "Import Settings from JetBrains IDE" });
+ expect(list).toHaveFocus();
+ expect(screen.getByRole("option", { name: idea.ide })).toHaveAttribute("aria-selected", "true");
+ await act(async () => {
+ fireEvent.keyDown(list, { key: "ArrowDown" });
+ });
+ expect(screen.getByRole("option", { name: studio.ide })).toHaveAttribute("aria-selected", "true");
+ await act(async () => {
+ fireEvent.keyDown(list, { key: "Enter" });
+ await done;
+ });
+ expect(importJetBrainsSettings).toHaveBeenCalledExactlyOnceWith(studio.path);
+ });
+
+ it("imports nothing when the dialog is cancelled", async () => {
+ listIdes.mockResolvedValue([idea]);
+ let done!: Promise<void>;
+ await act(async () => {
+ done = importFromJetBrainsIde();
+ });
+ await act(async () => {
+ fireEvent.keyDown(screen.getByRole("listbox"), { key: "Escape" });
+ await done;
+ });
+ expect(importJetBrainsSettings).not.toHaveBeenCalled();
+ expect(notify).not.toHaveBeenCalled();
+ });
+
+ it("says so, without a dialog, when no JetBrains IDE has settings on this computer", async () => {
+ listIdes.mockResolvedValue([]);
+ await importFromJetBrainsIde();
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+ expect(notify).toHaveBeenCalledWith(
+ expect.objectContaining({ level: "warning", title: "No JetBrains IDE settings were found on this computer" }),
+ );
+ });
+
+ it("reports a failure to list or read the folders", async () => {
+ listIdes.mockRejectedValue(new Error("denied"));
+ await importFromJetBrainsIde();
+ expect(notify).toHaveBeenCalledWith(expect.objectContaining({ level: "error", title: "Cannot import settings" }));
+ });
+
+ it("keeps many product versions in the shared scroll list and selects by keyboard", async () => {
+ const ides = Array.from({ length: 60 }, (_, i) => ({
+ ide: `IntelliJ IDEA 2025.${i}`,
+ path: `/settings/idea${i}`,
+ }));
+ listIdes.mockResolvedValue(ides);
+ let done!: Promise<void>;
+ await act(async () => {
+ done = importFromJetBrainsIde();
+ });
+ const list = screen.getByRole("listbox");
+ expect(list).toHaveClass(pickerStyles.list!, listStyles.list!);
+ expect(list).toHaveFocus();
+ expect(screen.getAllByRole("option")[0]).toHaveAttribute("aria-setsize", "60");
+ expect(screen.getAllByRole("button").length).toBeLessThan(6);
+ await act(async () => {
+ fireEvent.keyDown(list, { key: "End" });
+ });
+ await act(async () => {
+ fireEvent.click(screen.getByRole("button", { name: "OK" }));
+ await done;
+ });
+ expect(importJetBrainsSettings).toHaveBeenCalledExactlyOnceWith(ides[59]!.path);
+ });
+});
diff --git a/src/features/app/projectActions.ts b/src/features/app/projectActions.ts
index 85499970e..a538dae16 100644
--- a/src/features/app/projectActions.ts
+++ b/src/features/app/projectActions.ts
@@ -8,8 +8,7 @@ import { isPowerSaveMode } from "@/platform/editorSettings";
import { call, commands, isTauri } from "@/platform/ipc";
import { useProject } from "@/platform/project";
import { notifications, registerEditorBanner } from "@/workbench/contributions";
-import { promptInput } from "@/workbench/inputDialogs";
-import { ask } from "@/workbench/messages";
+import { pickItems, promptInput } from "@/workbench/inputDialogs";
import { importJetBrainsSettings } from "./jetbrainsSettings";
import { showNewProject } from "./NewProject";
import { tx } from "@/platform/i18n";
@@ -127,13 +126,12 @@ export async function importFromJetBrainsIde() {
});
return;
}
- const { button } = await ask({
+ const picked = await pickItems({
title: tx("Import Settings from JetBrains IDE"),
- body: tx("Choose the IDE to import settings from:"),
- buttons: ides.map((ide, i) => ({ id: String(i), label: ide.ide, primary: i === 0 })),
+ items: ides.map((ide) => ({ key: ide.path, label: ide.ide })),
+ multiple: false,
});
- const chosen = ides[Number(button)];
- if (chosen) await importJetBrainsSettings(chosen.path);
+ if (picked?.[0]) await importJetBrainsSettings(picked[0]);
} catch (e) {
notifications().notify({
level: "error",
diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json
index 393370dff..1a07e3099 100644
--- a/src/platform/locales/text/en.json
+++ b/src/platform/locales/text/en.json
@@ -143,7 +143,6 @@
"Import JetBrains Settings": "Import JetBrains Settings",
"Import Settings from JetBrains IDE": "Import Settings from JetBrains IDE",
"Import Settings from JetBrains IDE…": "Import Settings from JetBrains IDE…",
- "Choose the IDE to import settings from:": "Choose the IDE to import settings from:",
"No JetBrains IDE settings were found on this computer": "No JetBrains IDE settings were found on this computer",
"These settings will be imported:": "These settings will be imported:",
"Not imported:": "Not imported:",
diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json
index 3fdc87809..84da68a72 100644
--- a/src/platform/locales/text/zh.json
+++ b/src/platform/locales/text/zh.json
@@ -3158,7 +3158,6 @@
"Import JetBrains Settings": "导入 JetBrains 设置",
"Import Settings from JetBrains IDE": "从 JetBrains IDE 导入设置",
"Import Settings from JetBrains IDE…": "从 JetBrains IDE 导入设置…",
- "Choose the IDE to import settings from:": "选择要从中导入设置的 IDE:",
"No JetBrains IDE settings were found on this computer": "此电脑上没有找到 JetBrains IDE 的设置",
"These settings will be imported:": "将导入以下设置:",
"Not imported:": "不导入:",