Add newline placeholder in Ktxt2

This commit is contained in:
2021-12-03 15:58:17 -07:00
parent 3a3d69d13a
commit eaaf443ca2
2 changed files with 12 additions and 4 deletions

View File

@@ -67,8 +67,11 @@
"${blockStartEnd}${source}$(if outputLocked lockedStart unlockedStart)${output}${blockStartEnd}")))) "${blockStartEnd}${source}$(if outputLocked lockedStart unlockedStart)${output}${blockStartEnd}"))))
// To save window space after each block editor, ¶ can be used in place of \n\n // To save window space after each block editor, ¶ can be used in place of \n\n
// and ↵ in place of \n
(function :String applySpecialChars [:String text] (function :String applySpecialChars [:String text]
(text.replace "¶" "\n\n")) (.replace
(text.replace "¶" "\n\n")
"↵" "\n"))
// Return [sourceFile outputFile] // Return [sourceFile outputFile]
(function :Array<String> extractFileContents [:Stream fileStream :String->Dynamic reportError] (function :Array<String> extractFileContents [:Stream fileStream :String->Dynamic reportError]

View File

@@ -10,9 +10,14 @@
(defNew [&prop :ExtensionContext context]) (defNew [&prop :ExtensionContext context])
(method :String insertSpecialChars [:String text] (method :String insertSpecialChars [:String text]
(if (text.endsWith "\n\n") (let [text (text.replace "\r" "")]
(+ (text.substr 0 (- text.length 2)) "¶") (cond
text)) ((text.endsWith "\n\n")
(+ (substr text 0 -2) "¶"))
((text.endsWith "\n")
(+ (substr text 0 -1) "↵"))
(true
text))))
(method :Promise<Void> resolveCustomTextEditor [:TextDocument document :WebviewPanel webviewPanel :CancellationToken _token] (method :Promise<Void> resolveCustomTextEditor [:TextDocument document :WebviewPanel webviewPanel :CancellationToken _token]
(set webviewPanel.webview.options (object enableScripts true)) (set webviewPanel.webview.options (object enableScripts true))