GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(tui): match the empty dialog search cursor to the highlighted row… · jonBoone/opencode@149767c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/tui
    • src/ui
      • dialog-select.tsx
    • test/cli/tui
      • dialog-select.test.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/tui/src/ui/dialog-select.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/src/ui/dialog-select.tsx
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,13 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
653653

654654
const searchInTitle = () => newDesigns() && props.searchInTitle === true && props.renderFilter !== false
655655

656+
// Terminals paint the glyph under a block cursor in their own color, so a near-white cursor hides the
657+
// placeholder's first letter. Until the user types, match the highlighted row so that letter shows through.
658+
const searchCursorColor = () => {
659+
if (!newDesigns()) return theme.text.formfield.focused
660+
return store.filter.length > 0 ? theme.text.base : theme.background.action.primary.focused
661+
}
662+
656663
const searchInput = () => (
657664
<input
658665
flexGrow={1}
@@ -664,7 +671,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
664671
})
665672
}}
666673
focusedBackgroundColor={theme.background.formfield.focused}
667-
cursorColor={newDesigns() ? theme.text.base : theme.text.formfield.focused}
674+
cursorColor={searchCursorColor()}
668675
cursorStyle={config.cursor}
669676
focusedTextColor={newDesigns() ? theme.text.formfield.base : theme.text.formfield.focused}
670677
ref={(r) => {
Collapse file

‎packages/tui/test/cli/tui/dialog-select.test.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/test/cli/tui/dialog-select.test.tsx
+31-2Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
type DialogSelectProps,
1313
} from "../../../src/ui/dialog-select"
1414
import { truncateFilePath } from "../../../src/ui/file-path"
15+
import { getOpenCodeTheme } from "../../../src/theme"
16+
import { resolveThemeDocument } from "@opencode/theme/tui"
1517
import { stringWidth } from "../../../src/util/string-width"
1618
import { emptyThemeSource, tmpdir } from "../../fixture/fixture"
1719
import { TestTuiContexts } from "../../fixture/tui-environment"
@@ -23,10 +25,11 @@ async function renderSelect(
2325
onGlobal: () => void,
2426
onRow: (option: DialogSelectOption<string>) => void,
2527
current?: string,
28+
settings: Parameters<typeof createTuiResolvedConfig>[0] = {},
2629
) {
2730
const state = path.join(root, "state")
2831
await mkdir(state, { recursive: true })
29-
const config = createTuiResolvedConfig()
32+
const config = createTuiResolvedConfig(settings)
3033
const [{ ConfigProvider }, { ThemeProvider }, { Keymap }, { DialogProvider }, { DialogSelect }, { ToastProvider }] =
3134
await Promise.all([
3235
import("../../../src/config"),
@@ -375,6 +378,30 @@ test("dialog actions run without options while row actions still require a selec
375378
}
376379
})
377380

381+
test("matches the search cursor to the highlighted row until text is typed under new designs", async () => {
382+
await using tmp = await tmpdir()
383+
const theme = resolveThemeDocument(getOpenCodeTheme(), "dark")
384+
const app = await renderSelect(
385+
tmp.path,
386+
[{ title: "First", value: "first" }],
387+
() => {},
388+
() => {},
389+
undefined,
390+
{ experimental: { "new-designs": true } },
391+
)
392+
393+
try {
394+
await app.waitFor(() => app.renderer.getCursorState().visible)
395+
expect(app.renderer.getCursorState().color.toInts()).toEqual(theme.background.action.primary.focused.toInts())
396+
397+
await app.mockInput.typeText("f")
398+
await app.waitFor(() => app.renderer.getCursorState().color.equals(theme.text.base))
399+
expect(app.renderer.getCursorState().color.toInts()).toEqual(theme.text.base.toInts())
400+
} finally {
401+
app.renderer.destroy()
402+
}
403+
})
404+
378405
test("renders one gap before an empty state", async () => {
379406
await using tmp = await tmpdir()
380407
const app = await renderSelect(
@@ -638,7 +665,9 @@ test("dialog rows do not add renderer resize listeners", async () => {
638665
const before = count()
639666
// Mounting 30 rows must not add one resize listener per row (Node warns
640667
// past 10 listeners on one emitter).
641-
select.replaceOptions(Array.from({ length: 30 }, (_, index) => ({ title: `Item ${index}`, value: `item-${index}` })))
668+
select.replaceOptions(
669+
Array.from({ length: 30 }, (_, index) => ({ title: `Item ${index}`, value: `item-${index}` })),
670+
)
642671
await select.app.waitForVisualIdle()
643672
expect(count()).toBe(before)
644673
} finally {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.