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(settings): Export Settings includes IDE view options (#1095)

l0ng-ai6b9ab3b323ad
diff --git a/src/features/app/__tests__/newProject.test.ts b/src/features/app/__tests__/newProject.test.ts
index efedeabc9..3458d0700 100644
--- a/src/features/app/__tests__/newProject.test.ts
+++ b/src/features/app/__tests__/newProject.test.ts
@@ -18,11 +18,13 @@ describe("File › New Project…", () => {
});
describe("Manage IDE Settings › Export Settings…", () => {
- it("exports templates, macros and layouts, not per-project state", () => {
+ it("exports templates, macros, layouts and view options, not per-project state", () => {
const data: Record<string, string> = {
"openidea.liveTemplates.v1": "[]",
"openidea.macros.v1": "{}",
"openidea.toolWindowLayouts.v1": "{}",
+ "openidea.projectTree.options": '{"singleClickOpen":true}',
+ "openidea.projectTree.expanded:/p": "[]",
"openidea.runAnything.history.v1:/p": "[]",
};
const keys = Object.keys(data);
@@ -34,6 +36,7 @@ describe("Manage IDE Settings › Export Settings…", () => {
expect(Object.keys(exportedStorage(storage)).sort()).toEqual([
"openidea.liveTemplates.v1",
"openidea.macros.v1",
+ "openidea.projectTree.options",
"openidea.toolWindowLayouts.v1",
]);
});
diff --git a/src/features/app/projectActions.ts b/src/features/app/projectActions.ts
index 0ede70e04..1308ed2e1 100644
--- a/src/features/app/projectActions.ts
+++ b/src/features/app/projectActions.ts
@@ -21,13 +21,29 @@ export const EXPORTED_STORAGE = [
"openidea.toolWindowLayouts.",
];
+/** IDE-level preferences kept in localStorage, exported with the settings as well. */
+const EXPORTED_KEYS = new Set([
+ "openidea.projectTree.options",
+ "openidea.todo.v1",
+ "openidea.vim.v1",
+ "openidea.vcs.diffOptions",
+ "openidea.vcs.diffPreview",
+ "openidea.vcs.branchesPopup.options",
+ "openidea.merge.autoApplyNonConflicting",
+ "openidea.markdown.defaultMode",
+ "openidea.imageViewer.chessboard",
+ "openidea.welcome.reopenLastProject",
+]);
+
+const isExported = (key: string) => EXPORTED_KEYS.has(key) || EXPORTED_STORAGE.some((p) => key.startsWith(p));
+
export function exportedStorage(
storage: Pick<Storage, "length" | "key" | "getItem"> = localStorage,
): Record<string, string> {
const out: Record<string, string> = {};
for (let i = 0; i < storage.length; i++) {
const key = storage.key(i);
- if (!key || !EXPORTED_STORAGE.some((p) => key.startsWith(p))) continue;
+ if (!key || !isExported(key)) continue;
const value = storage.getItem(key);
if (value !== null) out[key] = value;
}
@@ -71,7 +87,7 @@ async function importSettings() {
try {
const result = await call(commands.settingsImport(path));
for (const [key, value] of Object.entries(result.storage))
- if (EXPORTED_STORAGE.some((p) => key.startsWith(p)))
+ if (isExported(key))
try {
localStorage.setItem(key, value);
} catch {
@@ -81,7 +97,7 @@ async function importSettings() {
notifications().notify({
level: "info",
title: "Settings imported",
- body: "Restart to apply imported templates, macros and layouts.",
+ body: "Restart to apply imported templates, macros, layouts and view options.",
key: "app.settingsImport",
sticky: true,
actions: [{ label: "Restart", run: () => void executeAction("app.restart") }],
diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json
index dda23592d..c09faefbf 100644
--- a/src/platform/locales/text/zh.json
+++ b/src/platform/locales/text/zh.json
@@ -2808,7 +2808,7 @@
"Import Settings": "导入设置",
"Import Settings…": "导入设置…",
"Settings imported": "设置已导入",
- "Restart to apply imported templates, macros and layouts.": "重启以应用导入的模板、宏和布局。",
+ "Restart to apply imported templates, macros, layouts and view options.": "重启以应用导入的模板、宏、布局和视图选项。",
"Cannot import settings": "无法导入设置",
"Rename Project": "重命名项目",
"Rename Project…": "重命名项目…",