Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,33 +152,43 @@ open class EditorActionsMenu(
getInstance().unregisterActionExecListener(this)
}

private fun shouldSuppressActionsMenu(): Boolean {
val searcher = editor.searcher
return searcher.isSearching || searcher.hasQuery()
}

protected open fun onSelectionChanged(event: SelectionChangeEvent) {
if (touchHandler.hasAnyHeldHandle()) {
if (shouldSuppressActionsMenu()) {
dismiss()
return
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (touchHandler.hasAnyHeldHandle()) return

if (event.isSelected) {
editor.post { displayWindow(isShowing) }
mLastPosition = -1
} else {
var show = false
if (
event.cause == SelectionChangeEvent.CAUSE_TAP &&
return
}

val shouldShow =
event.cause == SelectionChangeEvent.CAUSE_TAP &&
event.left.index == mLastPosition &&
!isShowing &&
!editor.text.isInBatchEdit
) {
editor.post(::displayWindow)
show = true

if (shouldShow) {
editor.post(::displayWindow)
} else {
dismiss()
}

mLastPosition =
if (event.cause == SelectionChangeEvent.CAUSE_TAP && !shouldShow) {
event.left.index
} else {
dismiss()
-1
}
mLastPosition =
if (event.cause == SelectionChangeEvent.CAUSE_TAP && !show) {
event.left.index
} else {
-1
}
}
}

protected open fun onScrollEvent() {
Expand Down Expand Up @@ -209,7 +219,7 @@ open class EditorActionsMenu(
return
}
dismiss()
if (!editor.cursor.isSelected) {
if (!editor.cursor.isSelected || shouldSuppressActionsMenu()) {
return
}
editor.postDelayed(
Expand Down Expand Up @@ -243,6 +253,11 @@ open class EditorActionsMenu(

@JvmOverloads
open fun displayWindow(update: Boolean = false) {
if (shouldSuppressActionsMenu()) {
dismiss()

return
}
var top: Int
val cursor = editor.cursor
top =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ open class IDEEditorSearcher(
this.searchOptions = searchOptions
}

override fun search(
query: String,
searchOptions: SearchOptions,
) {
if (query.isNotEmpty()) {
markSearching()
} else {
isSearching = false
}
super.search(query, searchOptions)
}

override fun replaceAll(
replacement: String,
whenFinished: Runnable?,
Expand Down Expand Up @@ -75,6 +87,7 @@ open class IDEEditorSearcher(

fun onClose() {
isSearching = false
stopSearch()
}

private fun markSearching() {
Expand Down
Loading