1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-25 00:34:09 +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() { get() {
val promptCharacterOffset1 = promptCharacterOffset val promptCharacterOffset1 = promptCharacterOffset
return if (promptCharacterOffset1 == null) visibleText else { return if (promptCharacterOffset1 == null) visibleText else {
if (promptCharacterOffset1 > visibleText.length) { if (promptCharacterOffset1 + 1 > visibleText.length) {
logger.error("promptCharacterOffset1 >= visibleText.length: $promptCharacterOffset1 >= ${visibleText.length}") logger.error("promptCharacterOffset1 > visibleText.length: ${promptCharacterOffset1 + 1} > ${visibleText.length}")
visibleText visibleText
} else { } else {
visibleText.removeRange(promptCharacterOffset1, promptCharacterOffset1 + 1) visibleText.removeRange(promptCharacterOffset1, promptCharacterOffset1 + 1)
@ -106,9 +106,13 @@ interface VimCommandLine {
fun clearPromptCharacter() { fun clearPromptCharacter() {
if (promptCharacterOffset == null) return if (promptCharacterOffset == null) return
setText(actualText) // Note: We have to set promptCharacterOffset to null first, because when we set the new text,
caret.offset = min(caret.offset, visibleText.length) // 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 promptCharacterOffset = null
setText(myActualText)
caret.offset = min(caret.offset, visibleText.length)
} }
fun clearCurrentAction() fun clearCurrentAction()