Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ Linux 递归监听需要为目录分别注册,超出上限时会退回手动
Enum、Interface、Struct,其余作为符号。界面字体统一为13pt,侧栏24pt行高与图标列对齐。

类型/符号只保留定义在项目目录内的结果,标准库、SDK 和第三方依赖不显示;用户
搜不到依赖里的名字时容易误判为语言服务没启动,所以两个页签后各放一个 ⓘ,说明
列出哪些种类、范围和对语言插件的依赖。上面的文件类选项只作用于 Core 的文件和
搜不到依赖里的名字时容易误判为语言服务没启动,所以两个页签的名称后各放一个 ⓘ,说明
列出哪些种类、范围和对语言插件的依赖。ⓘ 解释的是页签本身,所以和名称放在同一个
页签块里:选中底色、悬停和点击都覆盖名称和 ⓘ,点 ⓘ 也会切到该页签;块的外观取自
Viva 按钮配方,和其他页签一致。上面的文件类选项只作用于 Core 的文件和
内容搜索,到不了语言服务结果,这两个页签因此不显示筛选按钮,避免出现无效选项。
包含依赖等非项目结果需要 Core 和桌面端一起扩展,不在当前实现范围内。

Expand Down
66 changes: 54 additions & 12 deletions desktop/internal/workbench/search_everywhere_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/1lck/Lithe-IDEA/desktop/internal/icons"
"github.com/vivaui/viva/app"
"github.com/vivaui/viva/components"
"github.com/vivaui/viva/gfx"
"github.com/vivaui/viva/ui"
)
Expand Down Expand Up @@ -115,22 +116,21 @@ func (a *App) everywhereScopes(c ui.C, p *project, language i18n.Language) {
}
ui.Row(c).FillWidth().Gap(4).Items(ui.Center).Children(func() {
for index, label := range labels {
tab := ui.Button(c.KeyInt(index), label).Ghost()
if index == v.scope {
tab.Secondary()
var clicked bool
if key, help := everywhereScopeHelp(language, index); help != "" {
clicked = a.everywhereHelpTab(c.KeyInt(index), c.Key(key), language, label, help, index == v.scope)
} else {
tab := ui.Button(c.KeyInt(index), label).Ghost()
if index == v.scope {
tab.Secondary()
}
clicked = tab.Clicked()
}
if tab.Clicked() {
if clicked {
a.performed("workspace.searchEverywhere.scope", surfaceButton)
v.scope = index
a.focusEverywhere(p)
}
if key, help := everywhereScopeHelp(language, index); help != "" {
info := ui.Button(c.Key(key), i18n.Shared(language, "native.moreInformation")).Icon(icons.Info).IconOnly().Ghost().Size(18, 18).
Tooltip(help)
if info.Clicked() {
a.focusEverywhere(p)
}
}
}
ui.Spacer(c).Grow(1)
preview := ui.Button(c.Key("everywherePreview"), i18n.Shared(language, "native.showPreview")).Icon(icons.Eye).IconOnly().Ghost().
Expand All @@ -152,7 +152,49 @@ func (a *App) everywhereScopes(c ui.C, p *project, language i18n.Language) {
})
}

// everywhereScopeHelp is the key and text of the ⓘ after a tab: what the tab lists and
// A tab with an ⓘ starts with a button's own padding before its name, keeps the ⓘ close
// after the name, and leaves only a little room after the ⓘ, whose icon is already inset.
const (
everywhereHelpTabStartPad = 10
everywhereHelpTabGap = 2
everywhereHelpTabEndPad = 4
everywhereHelpInfoSize = 18
)

// everywhereHelpTab declares a tab whose ⓘ explains it, and reports a click on the tab or
// its ⓘ. The ⓘ belongs to the tab, so both sit in one block: the chosen fill, the hover
// and the click cover the name and the ⓘ together. The block takes the colors, radius and
// height the theme gives the other tabs' buttons (Ghost, Secondary when chosen), so it
// reads as one of them; the ⓘ stays a button of its own, so the pointer and the keyboard
// both reach its tooltip.
func (a *App) everywhereHelpTab(c, infoKey ui.C, language i18n.Language, label, help string, chosen bool) bool {
variant := components.ButtonGhost
if chosen {
variant = components.ButtonSecondary
}
rest := components.ButtonRecipe(a.theme, variant, gfx.State{})
hovered := components.ButtonRecipe(a.theme, variant, gfx.State{Hovered: true})
pressed := components.ButtonRecipe(a.theme, variant, gfx.State{Pressed: true})
focused := components.ButtonRecipe(a.theme, variant, gfx.State{FocusVisible: true})
metrics := a.theme.Metrics
tab := ui.ButtonBase(c, label).Height(metrics.ControlHeight).Shrink(0).
PadSides(0, everywhereHelpTabEndPad, 0, everywhereHelpTabStartPad).Gap(everywhereHelpTabGap).
Radius(rest.Radius).Items(ui.Center).
Hover(ui.Look{}.Background(hovered.Background)).Pressed(ui.Look{}.Background(pressed.Background)).
Focus(ui.Look{}.Ring(focused.RingWidth, focused.Ring))
if rest.Filled {
tab.Background(rest.Background)
}
var info ui.Box
tab.Children(func() {
ui.Text(c, label).FontSize(metrics.FontSizeM).Weight(gfx.WeightMedium).Color(rest.Foreground)
info = ui.Button(infoKey, i18n.Shared(language, "native.moreInformation")).Icon(icons.Info).IconOnly().Ghost().
Size(everywhereHelpInfoSize, everywhereHelpInfoSize).Tooltip(help)
})
return info.Clicked() || tab.Clicked()
}

// everywhereScopeHelp is the key and text of the ⓘ in a tab: what the tab lists and
// how far it reaches. Only the tabs that list what language servers report have one,
// since what they leave out (the standard library, dependencies) is not obvious.
func everywhereScopeHelp(language i18n.Language, scope int) (string, string) {
Expand Down
37 changes: 25 additions & 12 deletions desktop/internal/workbench/search_idea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ func TestEverywhereTypesAndSymbolsUseSeparateTabs(t *testing.T) {
}

// The Types and Symbols tabs list only what language servers report inside the
// project folder, so an ⓘ right after each tab says what it lists and how far it
// reaches. The filter's file options do not reach those results, so neither tab has a
// filter; the tabs that search files keep theirs.
// project folder, so an ⓘ inside each tab, right after its name, says what it lists
// and how far it reaches: the ⓘ explains the tab, so it shares the tab's block (its
// fill when selected, its click). The filter's file options do not reach those
// results, so neither tab has a filter; the tabs that search files keep theirs.
func TestEverywhereLanguageTabsExplainTheirScopeAndHaveNoFilter(t *testing.T) {
h := newHarness(t, &testKernel{Client: core.NewClient()})
h.app.everywhereView.delay = 0
Expand All @@ -72,15 +73,17 @@ func TestEverywhereLanguageTabsExplainTheirScopeAndHaveNoFilter(t *testing.T) {
return gfx.Hit{}, false
}
info := i18n.Shared(language, "native.moreInformation")
for _, tc := range []struct{ tab, next, help string }{
{tab: "desktop.everywhere.types", next: "desktop.everywhere.files", help: "desktop.everywhere.typesHelp"},
{tab: "desktop.everywhere.symbols", next: "desktop.everywhere.actions", help: "desktop.everywhere.symbolsHelp"},
for _, tc := range []struct {
scope int
tab, help string
}{
{scope: 1, tab: "desktop.everywhere.types", help: "desktop.everywhere.typesHelp"},
{scope: 3, tab: "desktop.everywhere.symbols", help: "desktop.everywhere.symbolsHelp"},
} {
help := i18n.Shared(language, tc.help)
tab, ok := control(i18n.Shared(language, tc.tab))
next, nextOK := control(i18n.Shared(language, tc.next))
if !ok || !nextOK {
t.Fatalf("the %s and %s tabs are not shown", tc.tab, tc.next)
if !ok {
t.Fatalf("the %s tab is not shown", tc.tab)
}
var button gfx.Hit
for _, hit := range h.driver.Snapshot().Hits {
Expand All @@ -91,8 +94,13 @@ func TestEverywhereLanguageTabsExplainTheirScopeAndHaveNoFilter(t *testing.T) {
if button.ID.IsZero() {
t.Fatalf("no ⓘ tells assistive technology %q", help)
}
if button.Bounds.X < tab.Bounds.Right() || button.Bounds.Right() > next.Bounds.X || button.Bounds.Bottom() < tab.Bounds.Y || button.Bounds.Y > tab.Bounds.Bottom() {
t.Fatalf("the ⓘ at %+v is not between the %s tab at %+v and the %s tab at %+v", button.Bounds, tc.tab, tab.Bounds, tc.next, next.Bounds)
// Inside the tab and at its end: the tab's name, then the ⓘ, then only the
// tab's own end padding.
if button.Bounds.X <= tab.Bounds.X || button.Bounds.Right() > tab.Bounds.Right() || button.Bounds.Y < tab.Bounds.Y || button.Bounds.Bottom() > tab.Bounds.Bottom() {
t.Fatalf("the ⓘ at %+v is not inside the %s tab at %+v", button.Bounds, tc.tab, tab.Bounds)
}
if end := tab.Bounds.Right() - button.Bounds.Right(); end > everywhereHelpTabEndPad {
t.Fatalf("the ⓘ ends %v before the %s tab does, want at most %v", end, tc.tab, everywhereHelpTabEndPad)
}
at := center(button.Bounds)
if err := h.driver.Move(at.X, at.Y); err != nil {
Expand All @@ -106,7 +114,12 @@ func TestEverywhereLanguageTabsExplainTheirScopeAndHaveNoFilter(t *testing.T) {
shown = append(shown, tip.Value)
}
if got := unspaced(strings.Join(shown, "")); got != unspaced(help) {
t.Fatalf("resting on the ⓘ after the %s tab shows %q, want only %q", tc.tab, shown, help)
t.Fatalf("resting on the ⓘ in the %s tab shows %q, want only %q", tc.tab, shown, help)
}
// The ⓘ is part of the tab, so a click on it chooses the tab.
h.click(at)
if got := h.app.everywhereView.scope; got != tc.scope {
t.Fatalf("a click on the ⓘ in the %s tab leaves tab %d chosen, want %d", tc.tab, got, tc.scope)
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading