fix prompt history behaviour and session line up/down commands (#26797)
This commit is contained in:
@@ -926,13 +926,7 @@ export function Prompt(props: PromptProps) {
|
|||||||
target: inputTarget,
|
target: inputTarget,
|
||||||
enabled: (() => {
|
enabled: (() => {
|
||||||
cursorVersion()
|
cursorVersion()
|
||||||
return (
|
return inputTarget() !== undefined && !props.disabled && !auto()?.visible && input !== undefined
|
||||||
inputTarget() !== undefined &&
|
|
||||||
!props.disabled &&
|
|
||||||
!auto()?.visible &&
|
|
||||||
input !== undefined &&
|
|
||||||
(input.cursorOffset === 0 || input.visualCursor.visualRow === 0)
|
|
||||||
)
|
|
||||||
})(),
|
})(),
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
@@ -941,12 +935,12 @@ export function Prompt(props: PromptProps) {
|
|||||||
category: "Prompt",
|
category: "Prompt",
|
||||||
run() {
|
run() {
|
||||||
if (input.cursorOffset !== 0) {
|
if (input.cursorOffset !== 0) {
|
||||||
input.cursorOffset = 0
|
if (input.scrollY + input.visualCursor.visualRow === 0) input.cursorOffset = 0
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const item = history.move(-1, input.plainText)
|
const item = history.move(-1, input.plainText)
|
||||||
if (!item) return
|
if (!item) return false
|
||||||
input.setText(item.input)
|
input.setText(item.input)
|
||||||
setStore("prompt", item)
|
setStore("prompt", item)
|
||||||
setStore("mode", item.mode ?? "normal")
|
setStore("mode", item.mode ?? "normal")
|
||||||
@@ -964,13 +958,7 @@ export function Prompt(props: PromptProps) {
|
|||||||
target: inputTarget,
|
target: inputTarget,
|
||||||
enabled: (() => {
|
enabled: (() => {
|
||||||
cursorVersion()
|
cursorVersion()
|
||||||
return (
|
return inputTarget() !== undefined && !props.disabled && !auto()?.visible && input !== undefined
|
||||||
inputTarget() !== undefined &&
|
|
||||||
!props.disabled &&
|
|
||||||
!auto()?.visible &&
|
|
||||||
input !== undefined &&
|
|
||||||
(input.cursorOffset === input.plainText.length || input.visualCursor.visualRow === input.height - 1)
|
|
||||||
)
|
|
||||||
})(),
|
})(),
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
@@ -979,12 +967,16 @@ export function Prompt(props: PromptProps) {
|
|||||||
category: "Prompt",
|
category: "Prompt",
|
||||||
run() {
|
run() {
|
||||||
if (input.cursorOffset !== input.plainText.length) {
|
if (input.cursorOffset !== input.plainText.length) {
|
||||||
input.cursorOffset = input.plainText.length
|
if (
|
||||||
return
|
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)
|
const item = history.move(1, input.plainText)
|
||||||
if (!item) return
|
if (!item) return false
|
||||||
input.setText(item.input)
|
input.setText(item.input)
|
||||||
setStore("prompt", item)
|
setStore("prompt", item)
|
||||||
setStore("mode", item.mode ?? "normal")
|
setStore("mode", item.mode ?? "normal")
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ export function Session() {
|
|||||||
title: "Line up",
|
title: "Line up",
|
||||||
value: "session.line.up",
|
value: "session.line.up",
|
||||||
category: "Session",
|
category: "Session",
|
||||||
enabled: false,
|
hidden: true,
|
||||||
run: () => {
|
run: () => {
|
||||||
scroll.scrollBy(-1)
|
scroll.scrollBy(-1)
|
||||||
dialog.clear()
|
dialog.clear()
|
||||||
@@ -756,7 +756,7 @@ export function Session() {
|
|||||||
title: "Line down",
|
title: "Line down",
|
||||||
value: "session.line.down",
|
value: "session.line.down",
|
||||||
category: "Session",
|
category: "Session",
|
||||||
enabled: false,
|
hidden: true,
|
||||||
run: () => {
|
run: () => {
|
||||||
scroll.scrollBy(1)
|
scroll.scrollBy(1)
|
||||||
dialog.clear()
|
dialog.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user