1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-04 16:34:02 +02:00

Fix issues with command line prompt processing

This commit is contained in:
Alex Plate 2025-02-24 13:59:31 +02:00
parent 6feb1a4525
commit a925676d64
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F

View File

@ -52,8 +52,8 @@ interface VimCommandLine {
get() {
val promptCharacterOffset1 = promptCharacterOffset
return if (promptCharacterOffset1 == null) visibleText else {
if (promptCharacterOffset1 > visibleText.length) {
logger.error("promptCharacterOffset1 >= visibleText.length: $promptCharacterOffset1 >= ${visibleText.length}")
if (promptCharacterOffset1 + 1 > visibleText.length) {
logger.error("promptCharacterOffset1 > visibleText.length: ${promptCharacterOffset1 + 1} > ${visibleText.length}")
visibleText
} else {
visibleText.removeRange(promptCharacterOffset1, promptCharacterOffset1 + 1)
@ -106,9 +106,13 @@ interface VimCommandLine {
fun clearPromptCharacter() {
if (promptCharacterOffset == null) return
setText(actualText)
caret.offset = min(caret.offset, visibleText.length)
// Note: We have to set promptCharacterOffset to null first, because when we set the new text,
// the listener will be called, which will try to get the actual text again. And, if this field isn't null,
// it will get an incorrect result.
val myActualText = actualText
promptCharacterOffset = null
setText(myActualText)
caret.offset = min(caret.offset, visibleText.length)
}
fun clearCurrentAction()