Skip to content

Commit

Permalink
feat(ui): scroll to end of text on insert and add interaction type check
Browse files Browse the repository at this point in the history
Scrolls the editor to the end of the text after inserting new characters and adds a check for the interaction type to control the display of run content. This ensures a better user experience and more flexible configuration options for ShireActionLocation.
  • Loading branch information
phodal committed Nov 26, 2024
1 parent c640da5 commit 4b3ecf8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import com.intellij.openapi.actionSystem.ex.ActionUtil
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorFactory
import com.intellij.openapi.editor.EditorKind
import com.intellij.openapi.editor.*
import com.intellij.openapi.editor.colors.EditorColorsListener
import com.intellij.openapi.editor.colors.EditorColorsManager
import com.intellij.openapi.editor.ex.EditorEx
Expand Down Expand Up @@ -78,6 +75,10 @@ class RightPanelView(
WriteCommandAction.runWriteCommandAction(project) {
val document = editor.document
document.insertString(document.textLength, char)

// scroll to the end
editor.caretModel.moveToOffset(document.textLength)
editor.scrollingModel.scrollToCaret(ScrollType.RELATIVE)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.ui.components.panels.NonOpaquePanel
import com.phodal.shirecore.ShireCoroutineScope
import com.phodal.shirecore.config.InteractionType
import com.phodal.shirecore.config.ShireActionLocation
import com.phodal.shirecore.runner.console.ShireConsoleViewBase
import com.phodal.shirelang.psi.ShireFile
Expand Down Expand Up @@ -80,6 +81,11 @@ open class ShireRunConfigurationProfileState(
isShowRunContent = false
}

val interaction = parsedResult.config?.interaction
if (interaction == InteractionType.RightPanel) {
isShowRunContent = false
}

console!!.print("Prepare for running ${configuration.name}...\n", ConsoleViewContentType.NORMAL_OUTPUT)
ShireCoroutineScope.scope(myProject).launch {
try {
Expand Down Expand Up @@ -162,7 +168,6 @@ class ShireProcessAdapter(val configuration: ShireConfiguration, val consoleView
}

class ShireExecutionConsole(project: Project, viewer: Boolean, var isStopped: Boolean = false): ConsoleViewImpl(project, viewer) {

private val output = StringBuilder()

override fun print(text: String, contentType: ConsoleViewContentType) {
Expand Down

0 comments on commit 4b3ecf8

Please sign in to comment.