Skip to content

Commit

Permalink
refactor(code-highlight): update button icon and improve file creatio…
Browse files Browse the repository at this point in the history
…n logic
  • Loading branch information
phodal committed Mar 10, 2025
1 parent 7ae6dcf commit 58c98f5
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import cc.unitmesh.devti.provider.RunService
import cc.unitmesh.devti.sketch.ui.LangSketch
import cc.unitmesh.devti.sketch.ui.LanguageSketchProvider
import cc.unitmesh.devti.util.parser.CodeFence
import com.intellij.icons.AllIcons
import com.intellij.ide.scratch.ScratchRootType
import com.intellij.lang.Language
import com.intellij.openapi.Disposable
Expand Down Expand Up @@ -348,16 +349,14 @@ open class CodeHighlightSketch(
* Add Write Command Action
*/
private fun CodeHighlightSketch.processWriteCommand(currentText: String) {
val button = JButton("Write to file").apply {
preferredSize = JBUI.size(100, 30)
val button = JButton("Write to file", AllIcons.Actions.MenuSaveall).apply {
preferredSize = JBUI.size(120, 30)

addActionListener {
val file = ScratchRootType.getInstance().createScratchFile(
project,
"DevIn-${System.currentTimeMillis()}.devin",
Language.findLanguageByID("DevIn"),
currentText
)
val newFileName = "DevIn-${System.currentTimeMillis()}.devin"
val language = Language.findLanguageByID("DevIn")
val file = ScratchRootType.getInstance()
.createScratchFile(project, newFileName, language, currentText)

if (file == null) {
return@addActionListener
Expand Down

0 comments on commit 58c98f5

Please sign in to comment.