Skip to content

Commit

Permalink
merge ideavim integration
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Oct 18, 2019
1 parent c4d1dde commit 84329aa
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changelog

### 3.6.0
### 3.5.8

AceJump now supports full-screen tagging.
Tagging improvements, support for external plugin integration, fixes #304, #255

### 3.5.7

Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/acejump/search/AceUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fun Editor.getView(): IntRange {
val height = getScreenHeight() + 2
val lastLine = visualLineToLogicalLine(firstVisibleLine + height)
var endOffset = getLineEndOffset(lastLine, true)
endOffset = normalizeOffset(lastLine, endOffset, true)
endOffset = normalizeOffset(lastLine, endOffset)
endOffset = min(max(0, document.textLength - 1), endOffset + 1)

return startOffset..endOffset
Expand Down Expand Up @@ -240,7 +240,7 @@ fun Editor.getLineStartOffset(line: Int) =
* end offset for the line
*/

fun Editor.getLineEndOffset(line: Int, allowEnd: Boolean) =
fun Editor.getLineEndOffset(line: Int, allowEnd: Boolean = true) =
when {
line < 0 -> 0
line >= getLineCount() -> getFileSize(allowEnd)
Expand Down Expand Up @@ -273,7 +273,7 @@ fun Editor.normalizeLine(line: Int) = max(0, min(line, getLineCount() - 1))
* @return The normalized column number
*/

fun Editor.normalizeOffset(line: Int, offset: Int, allowEnd: Boolean) =
fun Editor.normalizeOffset(line: Int, offset: Int, allowEnd: Boolean = true) =
if (getFileSize(allowEnd) == 0) 0 else
max(min(offset, getLineEndOffset(line, allowEnd)), getLineStartOffset(line))

Expand Down
19 changes: 9 additions & 10 deletions src/main/kotlin/org/acejump/search/Finder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,15 @@ object Finder : Resettable {
}

/**
* This method should not be inlined because it's used in IdeaVim integration plugin
* This method is used by IdeaVim integration plugin and must not be inlined.
*
* The default model is like that because if this function was called from
* the outer scope, it means that [results] are already collected and
* AceFindModel should be empty. Additionally, if
* AceFindModes.isRegex == true, only one symbol is highlighted in document.
* By default, when this function is called externally, [results] are already
* collected and [AceFindModel] should be empty. Additionally, if the flag
* [AceFindModel.isRegularExpressions] is true only one symbol is highlighted.
*/

@ExternalUsage
fun markResults(
results: SortedSet<Int>,
fun markResults(results: SortedSet<Int>,
model: AceFindModel = AceFindModel("", true)
) {
if (!skim) tag(model, results)
Expand Down Expand Up @@ -146,10 +145,10 @@ object Finder : Resettable {

private fun tag(model: AceFindModel, results: SortedSet<Int>) {
synchronized(this) { Tagger.markOrJump(model, results) }
val (iv, ov) = textHighlights.partition { it.startOffset in viewBounds }
val (ivb, ovb) = textHighlights.partition { it.startOffset in viewBounds }

iv.cull()
runLater { ov.cull() }
ivb.cull()
runLater { ovb.cull() }

if (model.stringToFind == query || model.isRegularExpressions)
Handler.repaintTagMarkers()
Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/org/acejump/search/Scanner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ internal object Scanner {
}.toSortedSet()

private fun Set<Int>.isCacheValidForRange() =
viewBounds.let { view ->
first() < view.first && last() > view.last
}
viewBounds.let { view -> first() < view.first && last() > view.last }

private fun CharSequence.findAll(regex: Regex, startingFromIndex: Int) =
generateSequence(
Expand Down
10 changes: 6 additions & 4 deletions src/main/kotlin/org/acejump/view/Boundary.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.acejump.view

import org.acejump.search.getLineEndOffset
import org.acejump.search.getLineStartOffset
import org.acejump.view.Model.editor
import org.acejump.view.Model.editorText
import org.acejump.view.Model.viewBounds
Expand Down Expand Up @@ -42,21 +44,21 @@ enum class Boundary: ClosedRange<Int> {
// Search on the current line
CURRENT_LINE_BOUNDARY {
override val start: Int
get() = editor.document.getLineStartOffset(editor.caretModel.logicalPosition.line)
get() = editor.getLineStartOffset(editor.caretModel.logicalPosition.line)
override val endInclusive: Int
get() = editor.document.getLineEndOffset(editor.caretModel.logicalPosition.line)
get() = editor.getLineEndOffset(editor.caretModel.logicalPosition.line)
},
// Search after caret within line
CURRENT_LINE_AFTER_CARET_BOUNDARY {
override val start: Int
get() = max(editor.caretModel.offset, viewBounds.first)
override val endInclusive: Int
get() = editor.document.getLineEndOffset(editor.caretModel.logicalPosition.line)
get() = editor.getLineEndOffset(editor.caretModel.logicalPosition.line)
},
// Search before caret within line
CURRENT_LINE_BEFORE_CARET_BOUNDARY {
override val start: Int
get() = editor.document.getLineStartOffset(editor.caretModel.logicalPosition.line)
get() = editor.getLineStartOffset(editor.caretModel.logicalPosition.line)
override val endInclusive: Int
get() = min(editor.caretModel.offset, viewBounds.last)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/acejump/view/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ object Model {
settings.isBlinkCaret = false
colorsScheme.setColor(CARET_COLOR, AceConfig.settings.jumpModeColor)
}
}
}
Binary file removed src/main/resources/eng.traineddata
Binary file not shown.

0 comments on commit 84329aa

Please sign in to comment.