summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/pierre
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-03-13 06:27:58 -0500
committerGitHub <[email protected]>2026-03-13 06:27:58 -0500
commit270cb0b8b4265ac0965ac8b94a58a3bca86fa558 (patch)
tree5a37c81bec1dea75b5c24f6aa8fb6a762d438f64 /packages/ui/src/pierre
parent46ba9c81703fc6e7db7e623a607eeaab94fcd00f (diff)
downloadopencode-270cb0b8b4265ac0965ac8b94a58a3bca86fa558.tar.gz
opencode-270cb0b8b4265ac0965ac8b94a58a3bca86fa558.zip
chore: cleanup (#17284)
Diffstat (limited to 'packages/ui/src/pierre')
-rw-r--r--packages/ui/src/pierre/file-find.ts42
1 files changed, 25 insertions, 17 deletions
diff --git a/packages/ui/src/pierre/file-find.ts b/packages/ui/src/pierre/file-find.ts
index ee608152d..692ab3167 100644
--- a/packages/ui/src/pierre/file-find.ts
+++ b/packages/ui/src/pierre/file-find.ts
@@ -1,4 +1,5 @@
-import { createEffect, createSignal, onCleanup, onMount } from "solid-js"
+import { createEffect, onCleanup, onMount } from "solid-js"
+import { createStore } from "solid-js/store"
export type FindHost = {
element: () => HTMLElement | undefined
@@ -107,11 +108,18 @@ export function createFileFind(opts: CreateFileFindOptions) {
let mode: "highlights" | "overlay" = "overlay"
let hits: Range[] = []
- const [open, setOpen] = createSignal(false)
- const [query, setQuery] = createSignal("")
- const [index, setIndex] = createSignal(0)
- const [count, setCount] = createSignal(0)
- const [pos, setPos] = createSignal({ top: 8, right: 8 })
+ const [state, setState] = createStore({
+ open: false,
+ query: "",
+ index: 0,
+ count: 0,
+ pos: { top: 8, right: 8 },
+ })
+ const open = () => state.open
+ const query = () => state.query
+ const index = () => state.index
+ const count = () => state.count
+ const pos = () => state.pos
const clearOverlayScroll = () => {
for (const el of overlayScroll) el.removeEventListener("scroll", scheduleOverlay)
@@ -200,8 +208,8 @@ export function createFileFind(opts: CreateFileFindOptions) {
clearOverlay()
clearOverlayScroll()
hits = []
- setCount(0)
- setIndex(0)
+ setState("count", 0)
+ setState("index", 0)
}
const positionBar = () => {
@@ -214,7 +222,7 @@ export function createFileFind(opts: CreateFileFindOptions) {
const title = parseFloat(getComputedStyle(root).getPropertyValue("--session-title-height"))
const header = Number.isNaN(title) ? 0 : title
- setPos({
+ setState("pos", {
top: Math.round(rect.top) + header - 4,
right: Math.round(window.innerWidth - rect.right) + 8,
})
@@ -318,8 +326,8 @@ export function createFileFind(opts: CreateFileFindOptions) {
const currentIndex = total ? Math.min(desired, total - 1) : 0
hits = ranges
- setCount(total)
- setIndex(currentIndex)
+ setState("count", total)
+ setState("index", currentIndex)
const active = ranges[currentIndex]
if (mode === "highlights") {
@@ -342,8 +350,8 @@ export function createFileFind(opts: CreateFileFindOptions) {
}
const close = () => {
- setOpen(false)
- setQuery("")
+ setState("open", false)
+ setState("query", "")
clearFind()
if (current === host) current = undefined
}
@@ -352,7 +360,7 @@ export function createFileFind(opts: CreateFileFindOptions) {
if (current && current !== host) current.close()
current = host
target = host
- if (!open()) setOpen(true)
+ if (!open()) setState("open", true)
requestAnimationFrame(() => {
apply({ scroll: true })
input?.focus()
@@ -366,7 +374,7 @@ export function createFileFind(opts: CreateFileFindOptions) {
if (total <= 0) return
const currentIndex = (index() + dir + total) % total
- setIndex(currentIndex)
+ setState("index", currentIndex)
const active = hits[currentIndex]
if (!active) return
@@ -449,8 +457,8 @@ export function createFileFind(opts: CreateFileFindOptions) {
input = el
},
setQuery: (value: string) => {
- setQuery(value)
- setIndex(0)
+ setState("query", value)
+ setState("index", 0)
apply({ reset: true, scroll: true })
},
focus,