дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Порівняти коміти
4
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
33bb5c5597 | ||
|
|
e36cd37e56 | ||
|
|
0f652824b3 | ||
|
|
10aa367df3 |
No files matched your search
@@ -223,6 +223,7 @@ pub fn spec(os: Os) -> Vec<Entry> {
|
||||
vec![
|
||||
act("file.newProject", "Project…"),
|
||||
act("workspace.create", "Workspace…"),
|
||||
act("vcs.cloneProject", "Project from Version Control…"),
|
||||
SEP,
|
||||
act("file.new", "File…"),
|
||||
act("file.newScratchFile", "Scratch File"),
|
||||
@@ -2014,7 +2015,14 @@ mod tests {
|
||||
};
|
||||
assert_eq!(
|
||||
action_ids(new),
|
||||
["file.newProject", "workspace.create", "file.new", "file.newScratchFile", "file.newUntitled"],
|
||||
[
|
||||
"file.newProject",
|
||||
"workspace.create",
|
||||
"vcs.cloneProject",
|
||||
"file.new",
|
||||
"file.newScratchFile",
|
||||
"file.newUntitled"
|
||||
],
|
||||
"{os:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -337,6 +337,20 @@ export function targetOf(id: string, database: string | null, current: string |
|
||||
/** Key of the Database tree node of database `name` of data source `id`. */
|
||||
export const databaseKey = (id: string, name: string) => `${id}/@${name}`;
|
||||
|
||||
/**
|
||||
* `expanded` without the Database tree nodes that show what target `id` loaded (a data source
|
||||
* id: the source and all its databases). Once that is forgotten, an expanded node would wait
|
||||
* for children nothing loads until it is expanded again.
|
||||
*/
|
||||
export function collapseTarget(expanded: ReadonlySet<string>, id: string): Set<string> {
|
||||
const { id: source, database } = splitTarget(id);
|
||||
const under = (key: string, node: string) => key === node || key.startsWith(`${node}/`);
|
||||
const shows = database
|
||||
? (key: string) => under(key, databaseKey(source, database)) || under(key, id)
|
||||
: (key: string) => under(key, source) || key.startsWith(`${source}:`);
|
||||
return new Set([...expanded].filter((key) => !shows(key)));
|
||||
}
|
||||
|
||||
const SSL_MODES: Record<string, DbSslMode> = {
|
||||
disable: "disable",
|
||||
disabled: "disable",
|
||||
|
||||
@@ -274,6 +274,31 @@ describe("database metadata request lifetimes", () => {
|
||||
expect(useDatabase.getState().connected.has("pg:app")).toBe(false);
|
||||
});
|
||||
|
||||
it("collapses the tree nodes of what a disconnect forgets", async () => {
|
||||
const tree = [
|
||||
"pg",
|
||||
"pg/@app",
|
||||
"pg/public",
|
||||
"pg/public/tables",
|
||||
"pg:other/public",
|
||||
"pg/@other",
|
||||
"pg2",
|
||||
"pg2/public",
|
||||
];
|
||||
useDatabase.setState({ treeExpanded: new Set(tree) });
|
||||
await disconnect("pg:other");
|
||||
expect([...useDatabase.getState().treeExpanded]).toEqual([
|
||||
"pg",
|
||||
"pg/@app",
|
||||
"pg/public",
|
||||
"pg/public/tables",
|
||||
"pg2",
|
||||
"pg2/public",
|
||||
]);
|
||||
await disconnect("pg");
|
||||
expect([...useDatabase.getState().treeExpanded]).toEqual(["pg2", "pg2/public"]);
|
||||
});
|
||||
|
||||
it("disconnects one database without invalidating its sibling", async () => {
|
||||
const response = deferred();
|
||||
backend.schemas.mockReturnValueOnce(response.promise);
|
||||
@@ -334,11 +359,14 @@ describe("database metadata request lifetimes", () => {
|
||||
});
|
||||
|
||||
describe("connection and metadata continuations", () => {
|
||||
it("reloads every level the tree had expanded after a data source is edited", async () => {
|
||||
it.each([
|
||||
["edited", () => saveSource({ ...pg, host: "new-host" }, undefined)],
|
||||
["renamed", () => renameSource("pg", "Renamed")],
|
||||
])("reloads every level the tree had expanded after a data source is %s", async (_, change) => {
|
||||
await loadSchemas("pg");
|
||||
await loadTables("pg", "public");
|
||||
await loadDetails("pg", "public", "users");
|
||||
await saveSource({ ...pg, host: "new-host" }, undefined);
|
||||
await change();
|
||||
const st = useDatabase.getState();
|
||||
expect(st.schemas.pg).toEqual({ status: "ok", value: ["public"] });
|
||||
expect(st.tables["pg\u0000public"]?.status).toBe("ok");
|
||||
|
||||
@@ -38,6 +38,7 @@ import { workflowSettings } from "@/platform/workflowSettings";
|
||||
import { ask, confirm } from "@/workbench/messages";
|
||||
import {
|
||||
activeSchema,
|
||||
collapseTarget,
|
||||
colorVar,
|
||||
connectRemedy,
|
||||
databaseKey,
|
||||
@@ -437,12 +438,8 @@ export async function duplicateSource(id: string): Promise<void> {
|
||||
export async function renameSource(id: string, name: string): Promise<void> {
|
||||
const src = sourceById(id);
|
||||
if (!src || !name.trim() || name.trim() === src.name) return;
|
||||
const sources = useDatabase.getState().sources.map((s) => (s.id === src.id ? { ...s, name: name.trim() } : s));
|
||||
forget(id);
|
||||
const current = sourceMutation(id);
|
||||
await call(commands.dbSaveSources(sources));
|
||||
if (!current()) return;
|
||||
await loadSources();
|
||||
// Saved like any edit, so what the tree had loaded under the source is loaded again.
|
||||
await saveSource({ ...src, name: name.trim() }, undefined);
|
||||
}
|
||||
|
||||
/** Removes the data source after asking (Database tree › Drop on a source). */
|
||||
@@ -572,6 +569,7 @@ export async function disconnect(id: string): Promise<void> {
|
||||
if (!targets.includes(id)) targets.push(id);
|
||||
const current = projectRequest();
|
||||
forget(id);
|
||||
useDatabase.setState((s) => ({ treeExpanded: collapseTarget(s.treeExpanded, id) }));
|
||||
const intent = {};
|
||||
for (const target of targets) connectionIntents.set(target, intent);
|
||||
if (!splitTarget(id).database) sourceConnectionIntents.set(id, {});
|
||||
|
||||
@@ -776,6 +776,36 @@ describe("project producers", () => {
|
||||
expect(produceContext({ path: `${ROOT}/a.tscn`, root: ROOT, configs: [] }, OPTIMISTIC)).toBeNull();
|
||||
});
|
||||
|
||||
it("Dart files of a Flutter app run as the app (flutter run -t) in the app's folder", () => {
|
||||
const flutter = [
|
||||
cfg({ id: "flutter:run", kind: "flutter", command: "flutter", args: ["run", "-t", "lib/main.dart"], cwd: "app" }),
|
||||
];
|
||||
const p = produceContext({ path: `${ROOT}/app/lib/demo.dart`, root: ROOT, configs: flutter }, ALL)!;
|
||||
expect(p).toMatchObject({ name: "demo.dart", scope: "file" });
|
||||
expect(p.config).toMatchObject({
|
||||
kind: "flutter",
|
||||
command: "flutter",
|
||||
args: ["run", "-t", "lib/demo.dart"],
|
||||
cwd: "app",
|
||||
debugAdapter: "dart",
|
||||
});
|
||||
// Its tests run with `flutter test`, a Dart package's with `dart test`.
|
||||
expect(run({ path: `${ROOT}/app/test/widget_test.dart`, root: ROOT, configs: flutter })).toMatchObject({
|
||||
command: "flutter",
|
||||
args: ["test", "test/widget_test.dart"],
|
||||
cwd: "app",
|
||||
});
|
||||
expect(run({ path: `${ROOT}/tool/test/gen_test.dart`, root: ROOT, configs: flutter })).toMatchObject({
|
||||
command: "/bin/dart",
|
||||
args: ["test", "tool/test/gen_test.dart"],
|
||||
});
|
||||
// Outside the app (a Dart package next to it): `dart run`.
|
||||
expect(run({ path: `${ROOT}/tool/gen.dart`, root: ROOT, configs: flutter })).toMatchObject({
|
||||
command: "/bin/dart",
|
||||
args: ["run", "tool/gen.dart"],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps package.json test files on the project's runner", () => {
|
||||
const p = produceContext(
|
||||
{ path: `${ROOT}/src/a.test.ts`, root: ROOT, configs, content: "test('x', () => {})" },
|
||||
|
||||
@@ -438,6 +438,7 @@ function site(input: ContextInput): FileSite {
|
||||
ruby: ["ruby", "rake", "rspec"],
|
||||
php: ["php", "phpunit", "composer"],
|
||||
zig: ["zig", "zig-application"],
|
||||
dart: ["flutter"],
|
||||
};
|
||||
const owner =
|
||||
inside && language
|
||||
@@ -992,8 +993,27 @@ export function produceFile(input: ContextInput, env: ToolEnv): Produced | null
|
||||
return simple(lang, s, env, lang, () => [s.arg]);
|
||||
case "r":
|
||||
return simple(lang, s, env, "r", () => [s.arg]);
|
||||
case "dart":
|
||||
case "dart": {
|
||||
// A file of a Flutter app runs as the app (`flutter run -t`), on the toolbar's device.
|
||||
const app = s.inProject
|
||||
? allClosest(
|
||||
input.configs.filter((c) => c.kind === "flutter"),
|
||||
s.idPath,
|
||||
)[0]
|
||||
: undefined;
|
||||
// A test file runs its tests (`flutter test` / `dart test`); `dart run` can't run Flutter code.
|
||||
const test = /_test\.dart$/.test(s.file);
|
||||
if (app && test)
|
||||
return { name: s.file, scope: "file", config: fileConfig(s, "dart", app.command, ["test", s.arg]) };
|
||||
if (app)
|
||||
return {
|
||||
name: s.file,
|
||||
scope: "file",
|
||||
config: fileConfig(s, "flutter", app.command, ["run", "-t", s.arg], "dart"),
|
||||
};
|
||||
if (test) return simple(lang, s, env, "dart", () => ["test", s.arg]);
|
||||
return simple(lang, s, env, "dart", () => ["run", s.arg], "dart");
|
||||
}
|
||||
case "scala":
|
||||
return simple(lang, s, env, "scala-cli", () => ["run", s.arg]);
|
||||
case "kotlin":
|
||||
|
||||
@@ -291,6 +291,15 @@ export function registerVcsActions(): () => void {
|
||||
keywords: ["clone", "checkout", "git"],
|
||||
run: (c) => showCloneDialog(typeof c.arg === "string" ? c.arg : ""),
|
||||
},
|
||||
{
|
||||
// File › New › Project from Version Control: the same dialog, under the name the File menu uses.
|
||||
id: "vcs.cloneProject",
|
||||
title: "Project from Version Control…",
|
||||
category: "File",
|
||||
icon: "git-pull",
|
||||
keywords: ["clone", "checkout", "git", "new project"],
|
||||
run: () => showCloneDialog(""),
|
||||
},
|
||||
{
|
||||
id: "vcs.push",
|
||||
title: "Push…",
|
||||
|
||||
@@ -201,6 +201,7 @@
|
||||
"menu.file.newScratchFile": "Scratch File",
|
||||
"menu.new": "New",
|
||||
"menu.workspace.create": "Workspace…",
|
||||
"menu.vcs.cloneProject": "Project from Version Control…",
|
||||
"menu.workspace.open": "Open Workspace…",
|
||||
"menu.workspace.manage": "Manage Workspace…",
|
||||
"menu.file.newUntitled": "Untitled File",
|
||||
|
||||
@@ -1514,6 +1514,7 @@
|
||||
"Generate Requests for Controller": "为控制器生成请求",
|
||||
"Generate…": "生成…",
|
||||
"Get from Version Control…": "从版本控制获取…",
|
||||
"Project from Version Control…": "来自版本控制的项目…",
|
||||
"Gevent compatible": "兼容 Gevent",
|
||||
"Git Branches": "Git 分支",
|
||||
"Git Log": "Git 日志",
|
||||
|
||||
@@ -201,6 +201,7 @@
|
||||
"menu.file.newScratchFile": "临时文件",
|
||||
"menu.new": "新建",
|
||||
"menu.workspace.create": "工作区…",
|
||||
"menu.vcs.cloneProject": "来自版本控制的项目…",
|
||||
"menu.workspace.open": "打开工作区…",
|
||||
"menu.workspace.manage": "管理工作区…",
|
||||
"menu.file.newUntitled": "无标题文件",
|
||||
|
||||
Reference in new issue
Заблокувати користувача