Hide the editor caret while another input has focus
The caret was drawn unconditionally, so it kept showing in the main edit window while key focus sat in the find bar's search input — reading as if the editor still had focus. drawWrappedText now takes the field's focus state and draws the caret only when the field is focused (editorElem.Focused follows FocusedElementID, which is find_bar while the find bar is open); the caret returns when focus comes back on close. e2e: the editor TextField reports unfocused while the find bar is open and focused again after close.
This commit is contained in:
@@ -113,6 +113,10 @@ func TestRealFile_FindBarAndNavigation(t *testing.T) {
|
||||
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))
|
||||
}
|
||||
// The editor field reports UNFOCUSED while the find bar is open (the
|
||||
// renderer hides its caret for unfocused fields; main hands key focus to
|
||||
// the search input).
|
||||
waitForEditorField(t, h, func(tf ui.TextField) bool { return !tf.Focused })
|
||||
|
||||
// Type the query through the same channel main uses.
|
||||
h.Logic().FindQueryChan() <- "NEEDLE" // case-insensitive
|
||||
@@ -190,6 +194,8 @@ func TestRealFile_FindBarAndNavigation(t *testing.T) {
|
||||
if focus.(string) != "editor_text" {
|
||||
t.Fatalf("focus %q, want editor_text after close", focus)
|
||||
}
|
||||
// And the editor field reports focused again (caret returns).
|
||||
waitForEditorField(t, h, func(tf ui.TextField) bool { return tf.Focused })
|
||||
}
|
||||
|
||||
func TestRealFile_FindMatchesSurviveEdits(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user