diff --git a/CHANGES.md b/CHANGES.md index 99451864..44b10690 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/src/main/kotlin/org/acejump/search/AceUtil.kt b/src/main/kotlin/org/acejump/search/AceUtil.kt index bacd60a1..fa8a7105 100755 --- a/src/main/kotlin/org/acejump/search/AceUtil.kt +++ b/src/main/kotlin/org/acejump/search/AceUtil.kt @@ -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 @@ -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) @@ -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)) diff --git a/src/main/kotlin/org/acejump/search/Finder.kt b/src/main/kotlin/org/acejump/search/Finder.kt index 075338d4..4688210a 100644 --- a/src/main/kotlin/org/acejump/search/Finder.kt +++ b/src/main/kotlin/org/acejump/search/Finder.kt @@ -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, + fun markResults(results: SortedSet, model: AceFindModel = AceFindModel("", true) ) { if (!skim) tag(model, results) @@ -146,10 +145,10 @@ object Finder : Resettable { private fun tag(model: AceFindModel, results: SortedSet) { 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() diff --git a/src/main/kotlin/org/acejump/search/Scanner.kt b/src/main/kotlin/org/acejump/search/Scanner.kt index 80ade95a..0c4d331f 100644 --- a/src/main/kotlin/org/acejump/search/Scanner.kt +++ b/src/main/kotlin/org/acejump/search/Scanner.kt @@ -27,9 +27,7 @@ internal object Scanner { }.toSortedSet() private fun Set.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( diff --git a/src/main/kotlin/org/acejump/view/Boundary.kt b/src/main/kotlin/org/acejump/view/Boundary.kt index 9d89265b..92c85cc9 100644 --- a/src/main/kotlin/org/acejump/view/Boundary.kt +++ b/src/main/kotlin/org/acejump/view/Boundary.kt @@ -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 @@ -42,21 +44,21 @@ enum class Boundary: ClosedRange { // 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) } diff --git a/src/main/kotlin/org/acejump/view/Model.kt b/src/main/kotlin/org/acejump/view/Model.kt index cd71b91d..34213695 100644 --- a/src/main/kotlin/org/acejump/view/Model.kt +++ b/src/main/kotlin/org/acejump/view/Model.kt @@ -64,4 +64,4 @@ object Model { settings.isBlinkCaret = false colorsScheme.setColor(CARET_COLOR, AceConfig.settings.jumpModeColor) } -} +} \ No newline at end of file diff --git a/src/main/resources/eng.traineddata b/src/main/resources/eng.traineddata deleted file mode 100644 index f4744c20..00000000 Binary files a/src/main/resources/eng.traineddata and /dev/null differ