mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: snippet unescape (#474)
This commit is contained in:
@@ -7,6 +7,7 @@ import app.termora.actions.AnAction
|
||||
import app.termora.actions.AnActionEvent
|
||||
import app.termora.terminal.ControlCharacters
|
||||
import app.termora.terminal.panel.TerminalWriter
|
||||
import org.apache.commons.text.StringEscapeUtils
|
||||
|
||||
class SnippetAction private constructor() : AnAction(I18n.getString("termora.snippet.title"), Icons.codeSpan) {
|
||||
companion object {
|
||||
@@ -25,15 +26,15 @@ class SnippetAction private constructor() : AnAction(I18n.getString("termora.sni
|
||||
fun runSnippet(snippet: Snippet, writer: TerminalWriter) {
|
||||
if (snippet.type != SnippetType.Snippet) return
|
||||
val map = mapOf(
|
||||
"\\r" to ControlCharacters.CR,
|
||||
"\\n" to ControlCharacters.LF,
|
||||
"\\t" to ControlCharacters.TAB,
|
||||
"\n" to ControlCharacters.LF,
|
||||
"\r" to ControlCharacters.CR,
|
||||
"\t" to ControlCharacters.TAB,
|
||||
"\b" to ControlCharacters.BS,
|
||||
"\\a" to ControlCharacters.BEL,
|
||||
"\\e" to ControlCharacters.ESC,
|
||||
"\\b" to ControlCharacters.BS,
|
||||
)
|
||||
|
||||
var text = snippet.snippet
|
||||
var text = StringEscapeUtils.unescapeJava(snippet.snippet)
|
||||
for (e in map.entries) {
|
||||
text = text.replace(e.key, e.value.toString())
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class SnippetPanel : JPanel(BorderLayout()), Disposable {
|
||||
properties.getString("SnippetPanel.LeftPanel.width", "180").toIntOrNull() ?: 180,
|
||||
-1
|
||||
)
|
||||
leftPanel.minimumSize = Dimension(leftPanel.preferredSize.width, leftPanel.preferredSize.height)
|
||||
|
||||
rightPanel.border = BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createMatteBorder(0, 1, 0, 0, DynamicColor.BorderColor),
|
||||
|
||||
Reference in New Issue
Block a user