mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-30 14:03:31 +00:00
feat(app): update arrow buttons in review tab top bar (#39469)
Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
This commit is contained in:
parent
f720490219
commit
73009f0b09
1 changed files with 9 additions and 7 deletions
|
|
@ -165,11 +165,13 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||
}
|
||||
|
||||
const prev = () => {
|
||||
return props.files[fileIndex() - 1]
|
||||
if (!canCycle()) return
|
||||
return props.files[(fileIndex() - 1 + props.files.length) % props.files.length]
|
||||
}
|
||||
|
||||
const next = () => {
|
||||
return props.files[fileIndex() + 1]
|
||||
if (!canCycle()) return
|
||||
return props.files[(fileIndex() + 1) % props.files.length]
|
||||
}
|
||||
|
||||
const canCycle = () => props.files.length > 0
|
||||
|
|
@ -183,15 +185,15 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||
props.onSelectFile(file)
|
||||
}
|
||||
|
||||
// The prev/next tooltips advertise < and >; keep the keys working while the
|
||||
// Keep the advertised arrow keys working while the
|
||||
// pane is mounted, but never while typing in an input or comment editor.
|
||||
makeEventListener(document, "keydown", (event) => {
|
||||
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey) return
|
||||
if (event.key !== "<" && event.key !== ">") return
|
||||
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return
|
||||
const target = event.target
|
||||
if (target instanceof HTMLElement && (target.isContentEditable || target.closest("input, textarea, select"))) return
|
||||
if (!props.hasDiffs || !canCycle()) return
|
||||
const file = event.key === "<" ? prev() : next()
|
||||
const file = event.key === "ArrowLeft" ? prev() : next()
|
||||
if (!file) return
|
||||
event.preventDefault()
|
||||
cycle(file)
|
||||
|
|
@ -219,7 +221,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||
value={
|
||||
<>
|
||||
{i18n.t("ui.sessionReviewV2.previousFile")}
|
||||
<KeybindV2 keys={["<"]} variant="neutral" />
|
||||
<KeybindV2 keys={["←"]} variant="neutral" />
|
||||
</>
|
||||
}
|
||||
>
|
||||
|
|
@ -239,7 +241,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||
value={
|
||||
<>
|
||||
{i18n.t("ui.sessionReviewV2.nextFile")}
|
||||
<KeybindV2 keys={[">"]} variant="neutral" />
|
||||
<KeybindV2 keys={["→"]} variant="neutral" />
|
||||
</>
|
||||
}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue