mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-19 16:40:48 +00:00
fix prompt history behaviour and session line up/down commands (#26797)
This commit is contained in:
parent
cfbf5d1c6f
commit
721ff5121e
2 changed files with 14 additions and 22 deletions
|
|
@ -926,13 +926,7 @@ export function Prompt(props: PromptProps) {
|
|||
target: inputTarget,
|
||||
enabled: (() => {
|
||||
cursorVersion()
|
||||
return (
|
||||
inputTarget() !== undefined &&
|
||||
!props.disabled &&
|
||||
!auto()?.visible &&
|
||||
input !== undefined &&
|
||||
(input.cursorOffset === 0 || input.visualCursor.visualRow === 0)
|
||||
)
|
||||
return inputTarget() !== undefined && !props.disabled && !auto()?.visible && input !== undefined
|
||||
})(),
|
||||
commands: [
|
||||
{
|
||||
|
|
@ -941,12 +935,12 @@ export function Prompt(props: PromptProps) {
|
|||
category: "Prompt",
|
||||
run() {
|
||||
if (input.cursorOffset !== 0) {
|
||||
input.cursorOffset = 0
|
||||
return
|
||||
if (input.scrollY + input.visualCursor.visualRow === 0) input.cursorOffset = 0
|
||||
return false
|
||||
}
|
||||
|
||||
const item = history.move(-1, input.plainText)
|
||||
if (!item) return
|
||||
if (!item) return false
|
||||
input.setText(item.input)
|
||||
setStore("prompt", item)
|
||||
setStore("mode", item.mode ?? "normal")
|
||||
|
|
@ -964,13 +958,7 @@ export function Prompt(props: PromptProps) {
|
|||
target: inputTarget,
|
||||
enabled: (() => {
|
||||
cursorVersion()
|
||||
return (
|
||||
inputTarget() !== undefined &&
|
||||
!props.disabled &&
|
||||
!auto()?.visible &&
|
||||
input !== undefined &&
|
||||
(input.cursorOffset === input.plainText.length || input.visualCursor.visualRow === input.height - 1)
|
||||
)
|
||||
return inputTarget() !== undefined && !props.disabled && !auto()?.visible && input !== undefined
|
||||
})(),
|
||||
commands: [
|
||||
{
|
||||
|
|
@ -979,12 +967,16 @@ export function Prompt(props: PromptProps) {
|
|||
category: "Prompt",
|
||||
run() {
|
||||
if (input.cursorOffset !== input.plainText.length) {
|
||||
input.cursorOffset = input.plainText.length
|
||||
return
|
||||
if (
|
||||
input.scrollY + input.visualCursor.visualRow ===
|
||||
Math.max(0, input.editorView.getTotalVirtualLineCount() - 1)
|
||||
)
|
||||
input.cursorOffset = input.plainText.length
|
||||
return false
|
||||
}
|
||||
|
||||
const item = history.move(1, input.plainText)
|
||||
if (!item) return
|
||||
if (!item) return false
|
||||
input.setText(item.input)
|
||||
setStore("prompt", item)
|
||||
setStore("mode", item.mode ?? "normal")
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ export function Session() {
|
|||
title: "Line up",
|
||||
value: "session.line.up",
|
||||
category: "Session",
|
||||
enabled: false,
|
||||
hidden: true,
|
||||
run: () => {
|
||||
scroll.scrollBy(-1)
|
||||
dialog.clear()
|
||||
|
|
@ -756,7 +756,7 @@ export function Session() {
|
|||
title: "Line down",
|
||||
value: "session.line.down",
|
||||
category: "Session",
|
||||
enabled: false,
|
||||
hidden: true,
|
||||
run: () => {
|
||||
scroll.scrollBy(1)
|
||||
dialog.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue