Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 33bb5c5597 fix(run): run Dart test files with flutter test / dart test
A *_test.dart file ran with `dart run`, which can't load Flutter code
(dart:ui) and doesn't run package:test suites as tests. In a Flutter app
it now runs with `flutter test <file>` from the app's folder, elsewhere
with `dart test <file>`.
2026-11-19 11:16:54 +08:00
l0ng-ai e36cd37e56 fix(run): run a Flutter app's Dart files with flutter run (#4409)
Current File (and Run on a Dart file) ran `dart run <file>` even inside a
Flutter app, which can't start a Flutter program. In a folder with a
detected Flutter configuration the file now runs and debugs as the app,
`flutter run -t <file>` from the app's folder, on the toolbar's device.
Dart files outside a Flutter app keep `dart run`.
2026-11-19 11:01:17 +08:00
l0ng-ai 0f652824b3 fix(database): don't leave the tree loading after a disconnect or rename (#4406)
Disconnecting a data source (Deactivate, or Auto-disconnect when idle)
forgets what it loaded, but its expanded tree nodes stayed expanded and
showed Loading until collapsed by hand, since only expanding a node loads
its children. A disconnect now also collapses the nodes of what it
forgot: the source with all its databases, or one database. Renaming a
source dropped its metadata the same way; it now saves like any edit,
which reloads what the tree had expanded.

Fixes #4388
2026-11-19 10:51:01 +08:00
l0ng-ai 10aa367df3 feat(vcs): add File › New › Project from Version Control (#4398)
The clone dialog was only reachable from the Git menu and the welcome
screen. File › New now lists it too, as its own action
(vcs.cloneProject) since a menu bar holds each action id once.

Closes #4100
2026-11-19 10:35:19 +08:00
10 змінених файлів з 120 додано та 10 видалено

No files matched your search

+9 -1
Переглянути файл
@@ -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:?}"
);
}
+14
Переглянути файл
@@ -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",
+30 -2
Переглянути файл
@@ -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");
+4 -6
Переглянути файл
@@ -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, {});
+30
Переглянути файл
@@ -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', () => {})" },
+21 -1
Переглянути файл
@@ -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":
+9
Переглянути файл
@@ -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…",
+1
Переглянути файл
@@ -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",
+1
Переглянути файл
@@ -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 日志",
+1
Переглянути файл
@@ -201,6 +201,7 @@
"menu.file.newScratchFile": "临时文件",
"menu.new": "新建",
"menu.workspace.create": "工作区…",
"menu.vcs.cloneProject": "来自版本控制的项目…",
"menu.workspace.open": "打开工作区…",
"menu.workspace.manage": "管理工作区…",
"menu.file.newUntitled": "无标题文件",