diff --git a/desktop/internal/workbench/app.go b/desktop/internal/workbench/app.go index 900297a99a..d2f971ae1b 100644 --- a/desktop/internal/workbench/app.go +++ b/desktop/internal/workbench/app.go @@ -514,6 +514,8 @@ type App struct { // editorFocus is the document whose editor had the keyboard last frame; the file is // saved when the keyboard leaves it (document_autosave.go). editorFocus int + // statusPath is the navigation path at the leading end of the status bar (status_path.go). + statusPath statusPath // github is the GitHub account and its sign-in (github_account.go). github githubAccount // pullRequests is the pull-request panel of the Git log (github_prs.go). diff --git a/desktop/internal/workbench/chrome_view.go b/desktop/internal/workbench/chrome_view.go index 9bb26cb3c5..38822ec3d5 100644 --- a/desktop/internal/workbench/chrome_view.go +++ b/desktop/internal/workbench/chrome_view.go @@ -476,16 +476,14 @@ func (a *App) hiddenToolWindowRow(c ui.C, i int) (ui.Box, bool) { return row, row.Clicked() } -// statusBar is the strip across the bottom of the workbench: the project on the left, and at -// the trailing end the readouts the user can arrange. +// statusBar is the strip across the bottom of the workbench: the navigation path of the item the +// user is on at the leading end (status_path_view.go), and at the trailing end the readouts the +// user can arrange. func (a *App) statusBar(c ui.C) { clicked := -1 ui.Row(c).FillWidth().Height(statusBarHeight).Shrink(0).Background(a.chromeFill()). Items(ui.Center).PadX(chromeEdge).Children(func() { - k := c.Part("path") - ui.Text(k, a.project.name).Grow(1).Ellipsis().FontSize(a.theme.Metrics.FontSizeS).LineHeight(chromeLineHeight). - Color(a.colors.Subtle). - HitWith(ui.ID(k), a.text.Status.Path, gfx.HitOptions{Role: gfx.RoleStatus, Value: a.project.name, SkipFocus: true}) + a.statusPathView(c) zone := ui.Row(c).Items(ui.Center).Gap(chromeStatusGap).Children(func() { for _, i := range a.chrome.items[zoneStatus] { if !a.vimStatusShown(i) { diff --git a/desktop/internal/workbench/document_autosave.go b/desktop/internal/workbench/document_autosave.go index d2e7a123ce..89487c637e 100644 --- a/desktop/internal/workbench/document_autosave.go +++ b/desktop/internal/workbench/document_autosave.go @@ -65,11 +65,8 @@ func (a *App) noteEditorFocus(focused gfx.ID) { return } current := 0 - for _, d := range p.docs.list { - if d.view.Owns(focused) { - current = d.id - break - } + if d := p.documentOwning(focused); d != nil { + current = d.id } left := a.editorFocus a.editorFocus = current diff --git a/desktop/internal/workbench/status_path.go b/desktop/internal/workbench/status_path.go new file mode 100644 index 0000000000..941117185c --- /dev/null +++ b/desktop/internal/workbench/status_path.go @@ -0,0 +1,199 @@ +package workbench + +import ( + "path/filepath" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/vivaui/viva/gfx" +) + +// This file decides what the navigation path at the leading end of the status bar names. As in +// IntelliJ IDEA, the path follows the area the user last put the keyboard in, by a click or by the +// keyboard. The editor names its file, the Project tool window the row selected in it, and the +// Problems tool window the file of the problem selected in it. When the focus moves somewhere +// with no item of its own, such as a terminal, a button or a toolbar, the path keeps naming the +// area it named. The item is read from the area's current selection on every paint, so the path +// follows the arrow keys inside the area. status_path_view.go draws the path. + +// statusPathSource is the area whose current item the navigation path names. +type statusPathSource uint8 + +const ( + // statusPathEditor names the file of the selected editor tab. It is the source until the + // user focuses one of the others. + statusPathEditor statusPathSource = iota + // statusPathProject names the row selected in the Project tool window. + statusPathProject + // statusPathProblems names the file of the row selected in the Problems tool window. + statusPathProblems +) + +// statusPath is the state of the navigation path. +type statusPath struct { + source statusPathSource + // focus is the keyboard focus the source was last decided for. The source is decided again + // only when the focus moves. + focus gfx.ID + // root and file are the last absolute path made relative to the project. rel is what it + // gave, and inside says whether the file lies in the project. A paint that names the same + // file reuses them instead of allocating the relative path again. + root, file, rel string + inside bool + // valueOf is the project name and crumbs of the last path the bar drew, and value is the + // accessible value made from them. + valueOf statusValueKey + value string +} + +// statusCrumbs is what the path names after the project. rel is a project-relative path with +// forward slashes, and dir says its last segment is a folder. A document that is not in the +// project has no rel: name holds its name, and the path shows that name alone, without the +// project. When both rel and name are empty, the path names the project itself. +type statusCrumbs struct { + rel, name string + dir bool +} + +// statusValueKey is what the accessible value of the path is made from. +type statusValueKey struct { + project string + crumbs statusCrumbs +} + +// noteStatusPathFocus makes the area the focus moved into the source of the path. The status bar +// is declared after the editors and the tool windows, so the rows they declared in this paint are +// known. Focus on anything else leaves the source as it was. +func (a *App) noteStatusPathFocus(p *project, focused gfx.ID) { + s := &a.statusPath + if focused == s.focus { + return + } + s.focus = focused + switch { + case focused.IsZero(): + case p.documentOwning(focused) != nil: + s.source = statusPathEditor + case p.tree.rowFocused(focused): + s.source = statusPathProject + case a.problems.rowFocused(focused): + s.source = statusPathProblems + } +} + +// statusPathCrumbs is what the path names now: the current item of its source. A source with no +// current item, such as the Problems tool window after it closed, names the editor's file +// instead. With no file open, the path names the project alone. +func (a *App) statusPathCrumbs(p *project) statusCrumbs { + switch a.statusPath.source { + case statusPathProject: + if n := p.tree.selected; n != nil { + if n.path == "" { + return statusCrumbs{} + } + return statusCrumbs{rel: n.path, dir: n.dir} + } + case statusPathProblems: + if file, selected := a.problems.selectedFile(); selected { + if file == "" { + return statusCrumbs{} + } + return a.statusFileCrumbs(p, file, "") + } + case statusPathEditor: + } + d := a.selectedEditorDocument() + if d == nil { + return statusCrumbs{} + } + return a.statusFileCrumbs(p, d.path, d.name) +} + +// statusFileCrumbs names the file at the absolute path file. A file in the project is named by +// its path in the project. A file outside it, such as a scratch file or a document a plugin +// provides, is named by its name alone. name is the name a document shows in its tab; when it is +// empty, the last element of the path is used. +func (a *App) statusFileCrumbs(p *project, file, name string) statusCrumbs { + s := &a.statusPath + if s.root != p.root || s.file != file { + s.root, s.file = p.root, file + s.rel, s.inside = projectRelative(p.root, file) + } + if s.inside { + return statusCrumbs{rel: s.rel} + } + if name == "" { + name = filepath.Base(file) + } + return statusCrumbs{name: name} +} + +// statusPathValue is the accessible value of the path. It is the project and the crumbs after it +// joined by slashes, or a document's name when the document is not in the project. The value is +// made again only when the path changes. +func (a *App) statusPathValue(project string, crumbs statusCrumbs) string { + s := &a.statusPath + key := statusValueKey{project: project, crumbs: crumbs} + if s.valueOf == key { + return s.value + } + s.valueOf = key + switch { + case crumbs.name != "": + s.value = crumbs.name + case crumbs.rel == "": + s.value = project + default: + s.value = project + "/" + crumbs.rel + } + return s.value +} + +// documentOwning is the open document whose editor holds the control focused, or nil when no +// editor holds it. +func (p *project) documentOwning(focused gfx.ID) *document { + for _, d := range p.docs.list { + if d.view.Owns(focused) { + return d + } + } + return nil +} + +// rowFocused says whether focused is a row of the Project tool window's tree. +func (t *fileTree) rowFocused(focused gfx.ID) bool { + for i := range t.rows { + if t.view.RowID(i) == focused { + return true + } + } + return false +} + +// rowFocused says whether focused is a row of the Problems tool window's tree. +func (v *problemsView) rowFocused(focused gfx.ID) bool { + for i := range v.result.Rows { + if v.view.RowID(i) == focused { + return true + } + } + return false +} + +// selectedFile is the absolute path of the file the selected row belongs to. For a diagnostic, +// it is the diagnostic's file. For a file's node, it is that file. For a severity's node, it is +// empty. selected is false when no row is selected. +func (v *problemsView) selectedFile() (file string, selected bool) { + i := v.selectedRow + if i < 0 || i >= len(v.result.Rows) { + return "", false + } + if r := v.result.Rows[i]; r.Kind == core.ProblemsRowGroup { + g, ok := v.group(r.Group) + if !ok || g.Kind != core.ProblemsGroupByFile { + return "", ok + } + return g.FileKey, true + } + d, ok := v.shown(i) + return d.FileKey, ok +} diff --git a/desktop/internal/workbench/status_path_test.go b/desktop/internal/workbench/status_path_test.go new file mode 100644 index 0000000000..3afffb3695 --- /dev/null +++ b/desktop/internal/workbench/status_path_test.go @@ -0,0 +1,153 @@ +package workbench + +import ( + "os" + "path/filepath" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/vivaui/viva/gfx" +) + +// statusPathValue is the accessible value of the navigation path the status bar showed in the +// last frame: the project and the crumbs after it, joined by slashes. +func (h *harness) statusPathValue() string { + h.t.Helper() + for _, hit := range h.driver.Snapshot().Hits { + if hit.Role == gfx.RoleStatus && hit.Label == h.app.text.Status.Path { + return hit.Value + } + } + h.t.Fatal("the status bar shows no navigation path") + return "" +} + +// expectStatusPath paints what the last step did and fails unless the status bar's navigation +// path is then want. +func (h *harness) expectStatusPath(want string) { + h.t.Helper() + h.settle() + if got := h.statusPathValue(); got != want { + h.t.Fatalf("the status bar's path is %q, want %q", got, want) + } +} + +// statusPathFixture opens a project with src/main.go and notes.txt in the Project tool window. +func statusPathFixture(t *testing.T, h *harness) (p *project, source string) { + t.Helper() + root := t.TempDir() + source = filepath.Join(root, "src", "main.go") + if err := os.MkdirAll(filepath.Dir(source), 0o755); err != nil { + t.Fatal(err) + } + for _, file := range []string{source, filepath.Join(root, "notes.txt")} { + if err := os.WriteFile(file, []byte("text\n"), 0o600); err != nil { + t.Fatal(err) + } + } + p = h.openTree(t, root) + // A click leaves the pointer on the editor; ask for the hover at once instead of after the + // pointer rests, so a step does not wait out the delay. + h.app.semantics.hoverDelay = -1 + return p, source +} + +// openStatusPathFile opens file in an editor and clicks into the editor. +func (h *harness) openStatusPathFile(p *project, file string) { + h.t.Helper() + h.app.openFile(p, file) + h.settle() + d := p.docs.byPath(file) + if d == nil { + h.t.Fatalf("%s did not open", filepath.Base(file)) + } + h.press(h.topHit(d.hit)) +} + +// The path names the item of the area the user last clicked: the editor's file or the row +// selected in the Project tool window. +func TestStatusPathFollowsTheEditorAndTheProjectTree(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + p, source := statusPathFixture(t, h) + if got := h.statusPathValue(); got != p.name { + t.Fatalf("with no file open the path is %q, want the project %q", got, p.name) + } + + h.openStatusPathFile(p, source) + h.expectStatusPath(p.name + "/src/main.go") + for _, crumb := range []string{"src", "main.go"} { + if !h.shows(crumb) { + t.Fatalf("the path does not show the crumb %q", crumb) + } + } + + h.press(h.treeRowHit("src").Bounds) + h.expectStatusPath(p.name + "/src") + h.press(h.topHit(p.docs.byPath(source).hit)) + h.expectStatusPath(p.name + "/src/main.go") + // A click on a file's row opens it in the preview tab; the path names the row. + h.press(h.treeRowHit("notes.txt").Bounds) + h.expectStatusPath(p.name + "/notes.txt") + // The project's own row names the project alone; the click also closes it. + h.press(h.treeRowHit(p.name).Bounds) + h.expectStatusPath(p.name) +} + +// Focus on a terminal, which has no item, keeps the path, and a file outside the project is +// named by its name alone. +func TestStatusPathKeepsItsItemAndNamesAFileOutsideTheProject(t *testing.T) { + h := newHarness(t, &testKernel{Client: core.NewClient()}) + p, source := statusPathFixture(t, h) + h.openStatusPathFile(p, source) + h.press(h.treeRowHit("src").Bounds) + h.expectStatusPath(p.name + "/src") + + if !h.app.chrome.isOpen(catalogIndex[itemTerminal]) { + h.app.reduceChrome(core.SetChromeOpen(itemTerminal, true)) + h.settle() + } + if len(p.terms.list) != 1 { + t.Fatalf("the Terminal tool window opened %d terminals", len(p.terms.list)) + } + term := p.terms.list[0] + h.app.focusTerminal(term.id) + awaitDocumentState(t, h, func() bool { return term.view.Owns(h.driver.Snapshot().Focused) }) + if got := h.statusPathValue(); got != p.name+"/src" { + t.Fatalf("with the terminal focused the path is %q, want the tree's row kept", got) + } + + outside := filepath.Join(t.TempDir(), "outside.txt") + if err := os.WriteFile(outside, []byte("text\n"), 0o600); err != nil { + t.Fatal(err) + } + h.openStatusPathFile(p, outside) + h.expectStatusPath("outside.txt") +} + +// In the Problems tool window the path names the file of the selected row: a diagnostic's file +// or a file's node. +func TestStatusPathFollowsTheProblemsSelection(t *testing.T) { + h, a, _ := problemsTreeFixture(t) + name := h.app.project.name + h.clickNamed(problemsRowNamed(t, h, problemsDiagnosticRow(t, h, "note"))) + h.expectStatusPath(name + "/b.txt") + h.clickNamed(problemsRowNamed(t, h, a)) + h.expectStatusPath(name + "/a.txt") +} + +// A paint that names the same file as the paint before it makes no new strings. +func TestStatusPathReusesItsStringsWhileThePathStays(t *testing.T) { + root := t.TempDir() + a := &App{} + p := &project{root: root, name: filepath.Base(root)} + file := filepath.Join(root, "src", "main.go") + if got := a.statusPathValue(p.name, a.statusFileCrumbs(p, file, "main.go")); got != p.name+"/src/main.go" { + t.Fatalf("value = %q", got) + } + allocs := testing.AllocsPerRun(100, func() { + a.statusPathValue(p.name, a.statusFileCrumbs(p, file, "main.go")) + }) + if allocs != 0 { + t.Fatalf("a paint of the same path allocated %v times", allocs) + } +} diff --git a/desktop/internal/workbench/status_path_view.go b/desktop/internal/workbench/status_path_view.go new file mode 100644 index 0000000000..6410b5bc8c --- /dev/null +++ b/desktop/internal/workbench/status_path_view.go @@ -0,0 +1,60 @@ +package workbench + +import ( + "strings" + + "github.com/1lck/Lithe-IDEA/desktop/internal/fileicons" + "github.com/1lck/Lithe-IDEA/desktop/internal/icons" + "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui" +) + +// statusCrumbIcon is the size of the icon of the project and of the item the path names. +const statusCrumbIcon = 14 + +// statusPathView declares the navigation path at the leading end of the status bar. It shows the +// project, then each folder down to the item the path names (status_path.go), with a chevron +// between each two. As in IntelliJ IDEA's navigation bar, the project and the item carry their +// icons. A document outside the project shows only its own name and icon. The path takes the +// room the readouts at the trailing end leave, and a name short of room ends in an ellipsis. +func (a *App) statusPathView(c ui.C) { + p := a.project + a.noteStatusPathFocus(p, c.Canvas().Focused()) + crumbs := a.statusPathCrumbs(p) + value := a.statusPathValue(p.name, crumbs) + k := c.Part("path") + ui.Row(k).Grow(1).Shrink(1).MinWidth(0).Height(chromeStatusItem).Items(ui.Center).Gap(chromeGap).Clip(). + HitWith(ui.ID(k), a.text.Status.Path, gfx.HitOptions{Role: gfx.RoleStatus, Value: value, SkipFocus: true}). + Children(func() { + if crumbs.name != "" { + a.statusCrumbIcon(k, fileicons.ForFile(crumbs.name, a.colors.Dark)) + a.statusCrumbName(k, crumbs.name) + return + } + a.statusCrumbIcon(k, fileicons.ForDirectoryMark(fileicons.MarkModule, a.colors.Dark)) + a.statusCrumbName(k, p.name) + for rest := crumbs.rel; rest != ""; { + name, after, folder := strings.Cut(rest, "/") + rest = after + ui.Icon(k, icons.ChevronRight).Size(chromeMarkSize, chromeMarkSize).Shrink(0).Color(a.colors.Subtle) + switch { + case folder: + case crumbs.dir: + a.statusCrumbIcon(k, fileicons.ForDirectory(name, a.colors.Dark)) + default: + a.statusCrumbIcon(k, fileicons.ForFile(name, a.colors.Dark)) + } + a.statusCrumbName(k, name) + } + }) +} + +// statusCrumbIcon declares the icon of a crumb of the path. +func (a *App) statusCrumbIcon(c ui.C, icon gfx.Icon) { + ui.Icon(c, icon).Size(statusCrumbIcon, statusCrumbIcon).Shrink(0) +} + +// statusCrumbName declares the name of a crumb of the path. +func (a *App) statusCrumbName(c ui.C, name string) { + ui.Text(c, name).Ellipsis().FontSize(a.theme.Metrics.FontSizeS).LineHeight(chromeLineHeight).Color(a.colors.Subtle) +} diff --git a/desktop/internal/workbench/status_path_visual_test.go b/desktop/internal/workbench/status_path_visual_test.go new file mode 100644 index 0000000000..f8a919013a --- /dev/null +++ b/desktop/internal/workbench/status_path_visual_test.go @@ -0,0 +1,109 @@ +//go:build vivahead && lithevisual + +package workbench + +import ( + "os" + "path/filepath" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/plugindiag" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" + "github.com/vivaui/viva/app" + "github.com/vivaui/viva/headless" +) + +// TestVisualStatusPath captures the status bar's navigation path as it follows the area the user +// clicked: the editor's file, a folder selected in the Project tool window, and the file of a +// problem selected in the Problems tool window. Dark/light x Chinese/English are independent +// sessions and OS-free. +func TestVisualStatusPath(t *testing.T) { + out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") + if out == "" { + t.Skip("set LITHE_VISUAL_OUTPUT_DIR") + } + if err := os.MkdirAll(out, 0755); err != nil { + t.Fatal(err) + } + for _, look := range []struct{ theme, language string }{ + {"dark", "zh-Hans"}, {"dark", "en"}, + {"light", "zh-Hans"}, {"light", "en"}, + } { + t.Run(look.theme+"-"+look.language, func(t *testing.T) { + prefs := store.At(t.TempDir()) + if err := prefs.Save(settingsFile, settings{ + Theme: themeChoice(look.theme), Language: look.language, + DisableAutoSave: true, + }); err != nil { + t.Fatal(err) + } + root := filepath.Join(t.TempDir(), "shop") + folder := filepath.Join(root, "src", "main", "java", "shop") + if err := os.MkdirAll(folder, 0700); err != nil { + t.Fatal(err) + } + service := filepath.Join(folder, "OrderService.java") + order := filepath.Join(folder, "Order.java") + files := map[string]string{ + service: "package shop;\n\npublic class OrderService {\n public int total(Order order) {\n return order.price();\n }\n}\n", + order: "package shop;\n\npublic record Order(String name, int price) {\n public Order {\n if (price < 0) throw new IllegalArgumentException();\n }\n}\n", + } + for path, source := range files { + if err := os.WriteFile(path, []byte(source), 0600); err != nil { + t.Fatal(err) + } + } + var session *headless.Session + h := newHarnessWithDriver(t, Options{ + Kernel: &testKernel{Client: core.NewClient()}, + Store: prefs, Languages: []string{look.language}, + }, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1440, 900 + var err error + session, err = headless.Open(config, nil, headless.Options{}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + p := h.openTree(t, root) + shot := func(scene string) { + t.Helper() + h.settleChain() + if err := session.Screenshot(filepath.Join(out, "status-path-"+scene+"-"+look.theme+"-"+look.language+".png")); err != nil { + t.Fatal(err) + } + } + + // The editor names its file. + h.app.openFile(p, service) + h.settleChain() + d := p.docs.byPath(service) + if d == nil { + t.Fatal("the file did not open") + } + h.click(center(h.topHit(d.hit))) + h.expectStatusPath("shop/src/main/java/shop/OrderService.java") + shot("editor") + + // The Project tool window names the row selected in it: a click on a folder selects + // and opens it. + h.click(center(h.treeRowHit("src").Bounds)) + h.expectStatusPath("shop/src") + shot("project") + + // The Problems tool window names the file of the problem selected in it. + h.app.pluginDiagnostics = map[string]*plugindiag.Set{"demo": problemSet(t, + plugindiag.Diagnostic{FileKey: service, DisplayPath: "src/main/java/shop/OrderService.java", Line: 3, Column: 21, EndLine: 3, EndColumn: 26, Severity: plugindiag.SeverityWarning, Message: "Parameter can be final", Source: "Demo"}, + plugindiag.Diagnostic{FileKey: order, DisplayPath: "src/main/java/shop/Order.java", Line: 4, Column: 24, EndLine: 4, EndColumn: 54, Severity: plugindiag.SeverityWarning, Message: "Exception has no message", Source: "Demo"}, + )} + h.app.markProblemsChanged() + h.app.problems.project = true + openProblemsPanel(t, h) + h.clickNamed(problemsRowNamed(t, h, problemsDiagnosticRow(t, h, "Exception has no message"))) + h.expectStatusPath("shop/src/main/java/shop/Order.java") + shot("problems") + }) + } +} diff --git a/docs/assets/status-bar-navigation-path/after/status-path-editor-dark-en.png b/docs/assets/status-bar-navigation-path/after/status-path-editor-dark-en.png new file mode 100644 index 0000000000..3f27305b34 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-editor-dark-en.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-editor-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/after/status-path-editor-dark-zh-Hans.png new file mode 100644 index 0000000000..3f27305b34 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-editor-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-editor-light-en.png b/docs/assets/status-bar-navigation-path/after/status-path-editor-light-en.png new file mode 100644 index 0000000000..f260642b8a Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-editor-light-en.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-editor-light-zh-Hans.png b/docs/assets/status-bar-navigation-path/after/status-path-editor-light-zh-Hans.png new file mode 100644 index 0000000000..f260642b8a Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-editor-light-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-problems-dark-en.png b/docs/assets/status-bar-navigation-path/after/status-path-problems-dark-en.png new file mode 100644 index 0000000000..eed2d32193 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-problems-dark-en.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-problems-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/after/status-path-problems-dark-zh-Hans.png new file mode 100644 index 0000000000..eed2d32193 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-problems-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-problems-light-en.png b/docs/assets/status-bar-navigation-path/after/status-path-problems-light-en.png new file mode 100644 index 0000000000..49378a4995 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-problems-light-en.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-problems-light-zh-Hans.png b/docs/assets/status-bar-navigation-path/after/status-path-problems-light-zh-Hans.png new file mode 100644 index 0000000000..49378a4995 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-problems-light-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-project-dark-en.png b/docs/assets/status-bar-navigation-path/after/status-path-project-dark-en.png new file mode 100644 index 0000000000..3e5655d696 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-project-dark-en.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-project-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/after/status-path-project-dark-zh-Hans.png new file mode 100644 index 0000000000..3e5655d696 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-project-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-project-light-en.png b/docs/assets/status-bar-navigation-path/after/status-path-project-light-en.png new file mode 100644 index 0000000000..1ea64e022a Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-project-light-en.png differ diff --git a/docs/assets/status-bar-navigation-path/after/status-path-project-light-zh-Hans.png b/docs/assets/status-bar-navigation-path/after/status-path-project-light-zh-Hans.png new file mode 100644 index 0000000000..1ea64e022a Binary files /dev/null and b/docs/assets/status-bar-navigation-path/after/status-path-project-light-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-editor-dark-en.png b/docs/assets/status-bar-navigation-path/before/status-path-editor-dark-en.png new file mode 100644 index 0000000000..254bada145 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-editor-dark-en.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-editor-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/before/status-path-editor-dark-zh-Hans.png new file mode 100644 index 0000000000..254bada145 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-editor-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-editor-light-en.png b/docs/assets/status-bar-navigation-path/before/status-path-editor-light-en.png new file mode 100644 index 0000000000..6c08fb7be9 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-editor-light-en.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-editor-light-zh-Hans.png b/docs/assets/status-bar-navigation-path/before/status-path-editor-light-zh-Hans.png new file mode 100644 index 0000000000..6c08fb7be9 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-editor-light-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-problems-dark-en.png b/docs/assets/status-bar-navigation-path/before/status-path-problems-dark-en.png new file mode 100644 index 0000000000..5927d2b4ab Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-problems-dark-en.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-problems-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/before/status-path-problems-dark-zh-Hans.png new file mode 100644 index 0000000000..5927d2b4ab Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-problems-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-problems-light-en.png b/docs/assets/status-bar-navigation-path/before/status-path-problems-light-en.png new file mode 100644 index 0000000000..0a15813680 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-problems-light-en.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-problems-light-zh-Hans.png b/docs/assets/status-bar-navigation-path/before/status-path-problems-light-zh-Hans.png new file mode 100644 index 0000000000..0a15813680 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-problems-light-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-project-dark-en.png b/docs/assets/status-bar-navigation-path/before/status-path-project-dark-en.png new file mode 100644 index 0000000000..254bada145 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-project-dark-en.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-project-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/before/status-path-project-dark-zh-Hans.png new file mode 100644 index 0000000000..254bada145 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-project-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-project-light-en.png b/docs/assets/status-bar-navigation-path/before/status-path-project-light-en.png new file mode 100644 index 0000000000..6c08fb7be9 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-project-light-en.png differ diff --git a/docs/assets/status-bar-navigation-path/before/status-path-project-light-zh-Hans.png b/docs/assets/status-bar-navigation-path/before/status-path-project-light-zh-Hans.png new file mode 100644 index 0000000000..6c08fb7be9 Binary files /dev/null and b/docs/assets/status-bar-navigation-path/before/status-path-project-light-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/window/status-path-problems-dark-zh-Hans.png b/docs/assets/status-bar-navigation-path/window/status-path-problems-dark-zh-Hans.png new file mode 100644 index 0000000000..c4b35ded7d Binary files /dev/null and b/docs/assets/status-bar-navigation-path/window/status-path-problems-dark-zh-Hans.png differ diff --git a/docs/assets/status-bar-navigation-path/window/status-path-project-light-en.png b/docs/assets/status-bar-navigation-path/window/status-path-project-light-en.png new file mode 100644 index 0000000000..d7277270eb Binary files /dev/null and b/docs/assets/status-bar-navigation-path/window/status-path-project-light-en.png differ diff --git a/shared/platform-feature-matrix/features/workbench-status-bar-navigation-path.json b/shared/platform-feature-matrix/features/workbench-status-bar-navigation-path.json new file mode 100644 index 0000000000..779f8855ee --- /dev/null +++ b/shared/platform-feature-matrix/features/workbench-status-bar-navigation-path.json @@ -0,0 +1,31 @@ +{ + "id": "workbench-status-bar-navigation-path", + "area": "工作台", + "group": "工作台布局", + "capability": "状态栏左侧显示当前项的导航路径,跟随编辑器、项目树和问题窗口", + "macos": { + "implementationStatus": "implemented", + "verificationStatus": "pending", + "evidence": [ + "desktop/internal/workbench/status_path.go", + "desktop/internal/workbench/status_path_view.go", + "desktop/internal/workbench/chrome_view.go", + "desktop/internal/workbench/status_path_test.go", + "desktop/internal/workbench/status_path_visual_test.go" + ] + }, + "windows": { + "implementationStatus": "implemented", + "verificationStatus": "pending", + "evidence": [ + "desktop/internal/workbench/status_path.go", + "desktop/internal/workbench/status_path_view.go", + "desktop/internal/workbench/chrome_view.go", + "desktop/internal/workbench/status_path_test.go", + "desktop/internal/workbench/status_path_visual_test.go" + ] + }, + "owner": "Workbench", + "verification": "打开项目,确认没有打开文件时状态栏左侧只显示项目名。点击编辑器后显示“项目 › 目录 › … › 文件”,项目带模块图标、末项带文件图标;在项目树点选文件夹或文件,路径改为该行;点项目根行只显示项目名;在问题窗口选中某条问题或某个文件节点,路径改为该问题所在的文件,选中严重级别分组时只显示项目名。焦点移到终端、按钮等没有当前项的区域时路径保持不变;项目外的文件只显示文件名。窗口变窄时末尾名称以省略号截断,不挤压右侧的状态项。读屏软件读到的状态栏路径值为“项目/目录/文件”。自动化:status_path_test.go 的 TestStatusPathFollowsTheEditorAndTheProjectTree、TestStatusPathKeepsItsItemAndNamesAFileOutsideTheProject、TestStatusPathFollowsTheProblemsSelection、TestStatusPathReusesItsStringsWhileThePathStays;Viva 无头截图由 status_path_visual_test.go 的 TestVisualStatusPath 生成(明暗主题 × 中英文 × 编辑器/项目树/问题窗口三个场景)。", + "notes": "对齐 IntelliJ IDEA 状态栏的导航路径:来源按用户最后聚焦的区域决定(编辑器、项目树、问题窗口),焦点落在没有当前项的区域时沿用上一个来源;来源没有当前项时回退到编辑器的文件。项目树选中和问题窗口的选中与分组都来自 Core,路径只做呈现,用现有 projectRelative 换成项目相对路径。每帧不分配:相对路径和读屏值按输入记忆,目录名用 strings.Cut 取子串。点击某一段弹出同级列表、显示文件内符号(类、方法)、以及引用/查找等其他工具窗口作为来源暂未实现。" +}