1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2025-04-09 17:15:43 +02:00

Tag wrangling and jump point updates

This commit is contained in:
Breandan Considine 2016-10-05 20:23:08 -04:00
parent 08758d61be
commit b7a5800fff
3 changed files with 26 additions and 12 deletions
src/main/kotlin/com/johnlindquist/acejump

View File

@ -87,24 +87,31 @@ class AceFinder(val findManager: FindManager, val editor: EditorImpl) {
return {
//todo: refactor this mess
val text = findModel.stringToFind
var jumped = false;
if (text.isNotEmpty()) {
if (tagMap.containsKey(text))
listOf(JumpInfo(text, text, tagMap[text]!!, editor))
if (1 < text.length) {
if (tagMap.containsKey(text)) {
jumpTo(JumpInfo(text, text, tagMap[text]!!, editor))
jumped = true
} else if (1 < text.length) {
val last1: String = text.substring(text.length - 1)
if (tagMap.containsKey(last1))
listOf(JumpInfo(last1, text, tagMap[last1]!!, editor))
if (tagMap.containsKey(last1)) {
jumpTo(JumpInfo(last1, text, tagMap[last1]!!, editor))
jumped = true
}
if (2 < text.length) {
val last2: String = text.substring(text.length - 2)
if (tagMap.containsKey(last2))
listOf(JumpInfo(last2, text, tagMap[last2]!!, editor))
if (tagMap.containsKey(last2)) {
jumpTo(JumpInfo(last2, text, tagMap[last2]!!, editor))
jumped = true
}
}
}
}
jumpLocations = determineJumpLocations()
if (jumpLocations.size == 1)
jumpTo(jumpLocations.first())
if (!jumped) {
jumpLocations = determineJumpLocations()
if (jumpLocations.size == 1)
jumpTo(jumpLocations.first())
}
}
}

View File

@ -12,7 +12,12 @@ import java.awt.RenderingHints
class JumpInfo(private val tag: String, val search: String, val index: Int, val editor: EditorImpl) {
val window = editor.document.charsSequence
val source: String = window.substring(index, index + tag.length)
var offset = index - search.length + tag.length
var offset =
if (tag.isNotEmpty() && search.isNotEmpty() &&
tag.last() == search.last())
index - search.length + tag.length
else
index - search.length
val tagOffset = editor.offsetToVisualPosition(offset)
val tagPoint = getPointFromVisualPosition(editor, tagOffset).originalPoint

View File

@ -82,6 +82,8 @@ class SearchBox(val finder: AceFinder, val editor: EditorImpl) : JTextField() {
override fun actionPerformed(e: ActionEvent) =
keyMap[e.actionCommand[0].toInt()]!!.execute()
})
defaultKeyCommand.execute()
}
override fun processKeyEvent(p0: KeyEvent) {