fix prompt history behaviour and session line up/down commands (#26797)

This commit is contained in:
Sebastian 2026-05-11 04:27:46 +02:00 committed by GitHub
parent cfbf5d1c6f
commit 721ff5121e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 22 deletions

View file

@ -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")

View file

@ -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()