@@ -87,6 +87,21 @@ export class ScriptManager {
8787 return sortByProperty ( results , SORT_PROPERTY ) ;
8888 }
8989
90+ displayUserError ( errorObjectString : string ) {
91+ // TODO: Better origanisation for all patterns (regex, escpape char)
92+ const ESCAPE_LINE_FEED = / \\ n / g;
93+ const LINE_FEED = '\n' ;
94+ const AT_PATTERN = / \s * \s a t \s .[ ^ " ] * / g;
95+ const NOTHING = ' ' ;
96+
97+ let prettyErrorString = errorObjectString . replace (
98+ ESCAPE_LINE_FEED ,
99+ LINE_FEED
100+ ) ;
101+ prettyErrorString = prettyErrorString . replace ( AT_PATTERN , NOTHING ) ;
102+ this . replaceText ( prettyErrorString ) ;
103+ }
104+
90105 runScriptM ( scriptArguments : ScriptArguments ) {
91106 // Get clipboard content
92107 const clip = Clipboard . get ( ) ;
@@ -98,15 +113,15 @@ export class ScriptManager {
98113 this . replaceText ( result , clip ) ;
99114 }
100115
101- runScript ( script : Script , text : string ) {
116+ runScript ( script : Script , text : string ) : string {
102117 let scriptExecution = new ScriptExecution ( { text : text } ) ;
103118
104119 script . run ( scriptExecution ) ;
105120
106121 return scriptExecution . text ?? '' ;
107122 }
108123
109- replaceText ( newText : string , originText : string ) {
124+ replaceText ( newText : string , originText : string = '' ) {
110125 if ( newText !== originText ) {
111126 // Update clipboard with new value
112127 Clipboard . copy ( newText ) ;
0 commit comments