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

Fix an issue that the highlighting was silently missing due to an error

This commit is contained in:
Alex Plate 2025-02-24 12:13:51 +02:00
parent 2e8548cb25
commit e257a10525
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 16 additions and 5 deletions
src/main/java/com/maddyhome/idea/vim/ui/ex
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api

View File

@ -382,7 +382,7 @@ public class ExEntryPanel extends JPanel implements VimCommandLine {
catch (Throwable ex) {
// Make sure the exception doesn't leak out of the handler, because it can break the text entry field and
// require the editor to be closed/reopened. The worst that will happen is no incsearch highlights
logger.warn("Error while trying to show incsearch highlights", ex);
logger.error("Error while trying to show incsearch highlights", ex);
}
}
@ -397,7 +397,7 @@ public class ExEntryPanel extends JPanel implements VimCommandLine {
}
}
catch (Exception e) {
logger.warn("Cannot parse command for incsearch", e);
logger.error("Cannot parse command for incsearch", e);
}
return null;

View File

@ -49,8 +49,16 @@ interface VimCommandLine {
* This text represents the real content that is being processed or executed.
*/
val actualText: String
get() = if (promptCharacterOffset == null) visibleText else {
visibleText.removeRange(promptCharacterOffset!!, promptCharacterOffset!! + 1)
get() {
val promptCharacterOffset1 = promptCharacterOffset
return if (promptCharacterOffset1 == null) visibleText else {
if (promptCharacterOffset1 >= visibleText.length) {
logger.error("promptCharacterOffset1 >= visibleText.length: $promptCharacterOffset1 >= ${visibleText.length}")
visibleText
} else {
visibleText.removeRange(promptCharacterOffset1, promptCharacterOffset1 + 1)
}
}
}
/**
@ -98,9 +106,12 @@ interface VimCommandLine {
fun clearPromptCharacter() {
if (promptCharacterOffset == null) return
// 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.
promptCharacterOffset = null
setText(actualText)
caret.offset = min(caret.offset, visibleText.length)
promptCharacterOffset = null
}
fun clearCurrentAction()