дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
feat(workbench): Edit single files without opening a project (#145)
Files can now be opened without a project. A file dropped on the Welcome screen, picked with File › Open File…, or passed on the command line or to a second instance opens in a lightweight window: editor tabs only, with no project tree, indexing, language servers, VCS or project tool windows. Syntax highlighting, find, save, undo and Local History still work. More files opened later join the same window as new tabs. Open as Project in the status bar opens the file's directory as a full project, following the open-project policy, and reopens the file there. Backend: a light session reuses Project with an unindexed index, no LSP or VCS, and a flat watch on each opened file's directory. It is never reused as a project for the same root. Previously a file passed at launch opened its parent directory as a project.
Цей коміт міститься в:
1 джерело
eb67595e72
коміт
2d7726cf53
40 files changed
+1042
-140
No files matched your search
@@ -17,8 +17,10 @@
|
||||
"app.action.copy": "Copy",
|
||||
"app.action.cut": "Cut",
|
||||
"app.action.keymapReference": "Keymap Reference",
|
||||
"app.action.lightEditOpenProject": "Open Containing Folder as Project",
|
||||
"app.action.newWindow": "New Window",
|
||||
"app.action.nextWindow": "Next Project Window",
|
||||
"app.action.openFile": "Open File…",
|
||||
"app.action.openInNewWindow": "Open in New Window…",
|
||||
"app.action.openRecentProject": "Open Recent Project",
|
||||
"app.action.paste": "Paste",
|
||||
@@ -44,6 +46,8 @@
|
||||
"app.keymap.other": "Other",
|
||||
"app.keymap.preset": "Keymap: {preset}",
|
||||
"app.keymap.title": "Keymap Reference",
|
||||
"app.lightEdit.openProject": "Open as Project",
|
||||
"app.lightEdit.openProjectTooltip": "Open {folder} as a project",
|
||||
"app.log.failed": "Cannot show the log",
|
||||
"app.title.default": "OpenIDEA",
|
||||
"app.unsaved.body": "{count, plural, one {# file has} other {# files have}} unsaved changes in {project}. Save before closing?",
|
||||
@@ -60,6 +64,7 @@
|
||||
"app.update.none": "OpenIDEA {version} is up to date",
|
||||
"app.window.desktopOnly": "Multiple windows require the desktop app",
|
||||
"app.window.openFailed": "Cannot open {name}",
|
||||
"app.window.pickFileTitle": "Open File",
|
||||
"app.window.pickTitle": "Open in New Window",
|
||||
"app.window.askTitle": "Open Project",
|
||||
"app.window.askBody": "Projects can either be opened in a new window or replace the project in the current window.\nHow would you like to open \"{name}\"?",
|
||||
|
||||
@@ -571,7 +571,7 @@
|
||||
"Drop Commit": "丢弃提交",
|
||||
"Drop Commits": "丢弃提交",
|
||||
"Drop Stash": "丢弃储藏",
|
||||
"Drop a folder to open it as a project": "拖放文件夹以将其作为项目打开",
|
||||
"Drop a folder to open it as a project, or files to edit them": "拖放文件夹以将其作为项目打开,或拖放文件进行编辑",
|
||||
"Drop files here to open them": "将文件拖放到此处以打开",
|
||||
"Drop syntax trees and EditorConfig caches, compact the index": "丢弃语法树和 EditorConfig 缓存,压缩索引",
|
||||
"Drop…": "删除…",
|
||||
@@ -993,6 +993,7 @@
|
||||
"Leave a comment (required)": "留下评论(必填)",
|
||||
"Left Bottom": "左下",
|
||||
"Left Top": "左上",
|
||||
"LightEdit": "轻量编辑",
|
||||
"Limit body line": "限制正文行",
|
||||
"Limit history to": "历史记录限制为",
|
||||
"Limit subject line": "限制主题行",
|
||||
@@ -1253,6 +1254,7 @@
|
||||
"Open Folder": "打开文件夹",
|
||||
"Open In": "打开方式",
|
||||
"Open In Right Split": "在右侧拆分中打开",
|
||||
"Open Paths": "打开路径",
|
||||
"Open Project Path": "打开项目路径",
|
||||
"Open Projects": "打开的项目",
|
||||
"Open Recent…": "打开最近的项目…",
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
"app.action.copy": "复制",
|
||||
"app.action.cut": "剪切",
|
||||
"app.action.keymapReference": "快捷键参考",
|
||||
"app.action.lightEditOpenProject": "将所在文件夹作为项目打开",
|
||||
"app.action.newWindow": "新建窗口",
|
||||
"app.action.nextWindow": "下一个项目窗口",
|
||||
"app.action.openFile": "打开文件…",
|
||||
"app.action.openInNewWindow": "在新窗口中打开…",
|
||||
"app.action.openRecentProject": "打开最近的项目",
|
||||
"app.action.paste": "粘贴",
|
||||
@@ -44,6 +46,8 @@
|
||||
"app.keymap.other": "其他",
|
||||
"app.keymap.preset": "键位映射:{preset}",
|
||||
"app.keymap.title": "快捷键参考",
|
||||
"app.lightEdit.openProject": "作为项目打开",
|
||||
"app.lightEdit.openProjectTooltip": "将 {folder} 作为项目打开",
|
||||
"app.log.failed": "无法显示日志",
|
||||
"app.title.default": "OpenIDEA",
|
||||
"app.unsaved.body": "{project} 中有 {count} 个文件尚未保存。关闭前是否保存?",
|
||||
@@ -60,6 +64,7 @@
|
||||
"app.update.none": "OpenIDEA {version} 已是最新版本",
|
||||
"app.window.desktopOnly": "多窗口需要桌面应用",
|
||||
"app.window.openFailed": "无法打开 {name}",
|
||||
"app.window.pickFileTitle": "打开文件",
|
||||
"app.window.pickTitle": "在新窗口中打开",
|
||||
"app.window.askTitle": "打开项目",
|
||||
"app.window.askBody": "项目可以在新窗口中打开,也可以替换当前窗口中的项目。\n要如何打开“{name}”?",
|
||||
|
||||
@@ -8,9 +8,16 @@ interface ProjectState {
|
||||
/** Effective settings (project-layered when a project is open). */
|
||||
settings: Settings | null;
|
||||
opening: boolean;
|
||||
/** LightEdit: this window edits loose files without a project (`project` stays null). */
|
||||
lightEdit: boolean;
|
||||
}
|
||||
|
||||
export const useProject = create<ProjectState>(() => ({ project: null, settings: null, opening: false }));
|
||||
export const useProject = create<ProjectState>(() => ({
|
||||
project: null,
|
||||
settings: null,
|
||||
opening: false,
|
||||
lightEdit: false,
|
||||
}));
|
||||
|
||||
let leaveGuard: (() => Promise<boolean>) | null = null;
|
||||
|
||||
@@ -24,7 +31,8 @@ export function provideLeaveProjectGuard(guard: () => Promise<boolean>): () => v
|
||||
|
||||
/** False when the user chose to stay (another project in place, Close Project). */
|
||||
export function confirmLeaveProject(): Promise<boolean> {
|
||||
return useProject.getState().project && leaveGuard ? leaveGuard() : Promise.resolve(true);
|
||||
const s = useProject.getState();
|
||||
return (s.project || s.lightEdit) && leaveGuard ? leaveGuard() : Promise.resolve(true);
|
||||
}
|
||||
|
||||
let startupLaunch: Promise<void> | null = null;
|
||||
@@ -43,16 +51,22 @@ export async function openProject(path: string): Promise<ProjectInfo> {
|
||||
useProject.setState({ opening: true });
|
||||
try {
|
||||
const project = await call(commands.openProject(path));
|
||||
useProject.setState({ project, settings: project.settings });
|
||||
useProject.setState({ project, settings: project.settings, lightEdit: false });
|
||||
return project;
|
||||
} finally {
|
||||
useProject.setState({ opening: false });
|
||||
}
|
||||
}
|
||||
|
||||
/** Switches this window to LightEdit for the loose file `path` (kept when already in LightEdit). */
|
||||
export async function openLightEdit(path: string): Promise<void> {
|
||||
const settings = await call(commands.lightEditOpen(path));
|
||||
useProject.setState({ project: null, settings, lightEdit: true });
|
||||
}
|
||||
|
||||
export async function closeProject() {
|
||||
await commands.closeProject();
|
||||
useProject.setState({ project: null });
|
||||
useProject.setState({ project: null, lightEdit: false });
|
||||
}
|
||||
|
||||
export async function loadSettings() {
|
||||
|
||||
Reference in new issue
Заблокувати користувача