Skip to content

Commit

Permalink
attempt to fix acejump#446
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Sep 16, 2023
1 parent 64c6956 commit d905909
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 3.8.16

- Fix issue with unselectable tags, [#446](https://github.com/acejump/AceJump/issues/446)

## 3.8.15

- Forbid jumping to offscreen tags, [#442](https://github.com/acejump/AceJump/issues/442)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import org.jetbrains.changelog.date

plugins {
idea apply true
kotlin("jvm") version "1.9.10"
kotlin("jvm") version "1.9.20-Beta"
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.changelog") version "2.2.0"
id("com.github.ben-manes.versions") version "0.47.0"
id("com.github.ben-manes.versions") version "0.48.0"
}

tasks {
Expand Down Expand Up @@ -63,7 +63,7 @@ kotlin {
}
}

val acejumpVersion = "3.8.15"
val acejumpVersion = "3.8.16"

changelog {
version = acejumpVersion
Expand Down
21 changes: 10 additions & 11 deletions src/main/kotlin/org/acejump/AceUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package org.acejump

import com.anyascii.AnyAscii
import com.intellij.diff.util.DiffUtil.getLineCount
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.editor.*
import it.unimi.dsi.fastutil.ints.IntArrayList
import org.acejump.config.AceConfig
import java.awt.Point
import kotlin.math.*

/**
Expand Down Expand Up @@ -127,18 +129,15 @@ fun Editor.offsetCenter(first: Int, second: Int): LogicalPosition {
return offsetToLogicalPosition(getLineStartOffset(center))
}

// Borrowed from Editor.calculateVisibleRange() but only available after 232.6095.10
fun Editor.getView(): IntRange {
val firstVisibleLine = max(0, getVisualLineAtTopOfScreen() - 1)
val firstLine = visualLineToLogicalLine(firstVisibleLine)
val startOffset = getLineStartOffset(firstLine)

val height = getScreenHeight() + 2
val lastLine = visualLineToLogicalLine(firstVisibleLine + height)
var endOffset = getLineEndOffset(lastLine, true)
endOffset = normalizeOffset(lastLine, endOffset)
endOffset = min(max(0, document.textLength - 1), endOffset + 1)

return startOffset..endOffset
ApplicationManager.getApplication().assertIsDispatchThread()
val rect = scrollingModel.visibleArea
val startPosition = xyToLogicalPosition(Point(rect.x, rect.y))
val visibleStart = logicalPositionToOffset(startPosition)
val endPosition = xyToLogicalPosition(Point(rect.x + rect.width, rect.y + rect.height))
val visibleEnd = logicalPositionToOffset(LogicalPosition(endPosition.line + 1, 0))
return visibleStart..visibleEnd
}

/**
Expand Down

0 comments on commit d905909

Please sign in to comment.