Skip to content

Commit

Permalink
feat: show progress in searching
Browse files Browse the repository at this point in the history
close #1457
  • Loading branch information
hyoban committed Nov 8, 2024
1 parent 136aa20 commit e592e97
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/renderer/src/modules/panel/cmdf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const CmdFImpl: FC<{
onClose: () => void
}> = ({ onClose }) => {
const [value, setValue] = useState("")
const [activeMatchOrdinal, setActiveMatchOrdinal] = useState(0)
const [matches, setMatches] = useState(0)

const currentValue = useRefValue(value)
const inputRef = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -88,6 +90,10 @@ const CmdFImpl: FC<{
forward: dir === "forward",
},
})
.then((result) => {
setMatches(result?.matches || 0)
setActiveMatchOrdinal(result?.activeMatchOrdinal || 0)
})
.finally(() => {
if (searchId === searchIdRef.current) {
setIsSearching(false)
Expand Down Expand Up @@ -148,6 +154,11 @@ const CmdFImpl: FC<{
/>
</div>
<div className="center gap-1 [&>*]:opacity-80">
{!!value && matches > 0 && activeMatchOrdinal > 0 && (
<span>
{activeMatchOrdinal}/{matches}
</span>
)}
<button
type="button"
className="center hover:opacity-90"
Expand Down

0 comments on commit e592e97

Please sign in to comment.