Shrink the text area while the find bar is open
The find bar (32..72) used to be drawn over the top of the text area, covering the first visible line. EditorLayout now lowers the text area top by FindBarHeight (new shared constant) while the find bar is visible; it snaps back on close. e2e: assert the editor region top moves to 32+FindBarHeight while open.
This commit is contained in:
parent
78d240eedb
commit
153f555a23
|
|
@ -1857,6 +1857,10 @@ func markDirty() {
|
|||
}
|
||||
|
||||
// EditorLayout computes the element tree for the editor page.
|
||||
// FindBarHeight is the find bar's height; buildFindBar and EditorLayout
|
||||
// (which shrinks the text area to make room) both use it.
|
||||
const FindBarHeight = ui.Dp(40)
|
||||
|
||||
// buildFindBar lays out the in-file search bar: [input][counter][prev][next]
|
||||
// [close], full screen width, directly below the margin-free top bar (the
|
||||
// bars merge, so this one does too; inner content keeps the margin). The
|
||||
|
|
@ -1866,7 +1870,7 @@ func markDirty() {
|
|||
func buildFindBar(screenWidth ui.Dp) ui.Element {
|
||||
margin := ui.Dp(10)
|
||||
gap := ui.Dp(8)
|
||||
h := ui.Dp(40)
|
||||
h := FindBarHeight
|
||||
topY := ui.Dp(32) // top bar height (see EditorLayout)
|
||||
|
||||
// Right-hand button column: prev, next, close.
|
||||
|
|
@ -1988,7 +1992,12 @@ func EditorLayout(screenWidth, screenHeight ui.Dp, wordWrap bool) []ui.Element {
|
|||
}
|
||||
|
||||
// --- Editor text area ---
|
||||
// While the find bar is open it sits in [32, 32+FindBarHeight); shrink the
|
||||
// text area from the top so the first visible line is not covered.
|
||||
editorY := statusBarRegion.Y + statusBarRegion.H
|
||||
if TheState.Editor.Find.Visible {
|
||||
editorY += FindBarHeight
|
||||
}
|
||||
editorH := bottomBarRegion.Y - editorY
|
||||
editorRegion := ui.Region{
|
||||
X: margin, Y: editorY,
|
||||
|
|
|
|||
|
|
@ -80,6 +80,12 @@ func TestRealFile_FindBarAndNavigation(t *testing.T) {
|
|||
if focus.(string) != "find_bar" {
|
||||
t.Fatalf("focus %q, want find_bar", focus)
|
||||
}
|
||||
// The text area must shrink from the top while the find bar is open so
|
||||
// the first line is not covered: region top = top bar (32) + FindBarHeight.
|
||||
reg, _ := h.Inspect(func(st *editor.State) any { return st.EditorRegion })
|
||||
if got := reg.(ui.Region); got.Y != ui.Dp(32)+editor.FindBarHeight {
|
||||
t.Fatalf("editor region top %d, want %d (find bar must not cover text)", int(got.Y), int(ui.Dp(32)+editor.FindBarHeight))
|
||||
}
|
||||
|
||||
// Type the query through the same channel main uses.
|
||||
h.Logic().FindQueryChan() <- "NEEDLE" // case-insensitive
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user