mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[performance-plugin] AT-86 make GoToAnyPsiElement go forward in file
GitOrigin-RevId: f232e6a379a9b37b342fd5e51f8c0966dc6076ae
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ff74483fba
commit
21e8b188d9
@@ -67,7 +67,7 @@ public final class BaseCommandProvider implements CommandProvider {
|
||||
Map.entry(OpenRandomFileCommand.PREFIX, OpenRandomFileCommand::new),
|
||||
Map.entry(PressEnterKeyCommand.PREFIX, PressEnterKeyCommand::new),
|
||||
Map.entry(WaitForDumbCommand.PREFIX, WaitForDumbCommand::new),
|
||||
Map.entry(GoToAnyPsiElement.PREFIX, GoToAnyPsiElement::new)
|
||||
Map.entry(GoToNextPsiElement.PREFIX, GoToNextPsiElement::new)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ import org.jetbrains.concurrency.toPromise
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
class GoToAnyPsiElement(text: String, line: Int) : AbstractCommand(text, line) {
|
||||
class GoToNextPsiElement(text: String, line: Int) : AbstractCommand(text, line) {
|
||||
companion object {
|
||||
const val PREFIX: @NonNls String = CMD_PREFIX + "goToAnyPsiElement"
|
||||
const val PREFIX: @NonNls String = CMD_PREFIX + "goToNextPsiElement"
|
||||
const val SUPPRESS_ERROR_IF_NOT_FOUND: @NonNls String = "SUPPRESS_ERROR_IF_NOT_FOUND"
|
||||
val REGEX = " ".toRegex()
|
||||
}
|
||||
@@ -45,14 +45,17 @@ class GoToAnyPsiElement(text: String, line: Int) : AbstractCommand(text, line) {
|
||||
psiFile?.accept(object : PsiRecursiveElementWalkingVisitor(true) {
|
||||
override fun visitElement(element: PsiElement) {
|
||||
if (params.contains(element.elementType?.debugName)) {
|
||||
val spaceIndex = max(1, element.text.indexOf(" "))
|
||||
val offset = min(element.endOffset, element.startOffset + spaceIndex)
|
||||
if (editor.caretModel.offset == offset) {
|
||||
actionCallback.setDone()
|
||||
} else {
|
||||
editor.caretModel.moveToOffset(offset)
|
||||
if (editor.caretModel.currentCaret.offset < element.startOffset) {
|
||||
val spaceIndex = max(1, element.text.indexOf(" "))
|
||||
val offset = min(element.endOffset, element.startOffset + spaceIndex)
|
||||
if (editor.caretModel.offset == offset) {
|
||||
actionCallback.setDone()
|
||||
}
|
||||
else {
|
||||
editor.caretModel.moveToOffset(offset)
|
||||
}
|
||||
stopWalking()
|
||||
}
|
||||
stopWalking()
|
||||
}
|
||||
super.visitElement(element)
|
||||
}
|
||||
Reference in New Issue
Block a user