File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,15 +76,24 @@ export function formatPromptText(text) {
7676 // Handle null or undefined input
7777 if ( text == null ) return text ;
7878
79- // Trim surrounding spaces of the entire prompt if the setting is enabled
80- if ( settingValues . trimSurroundingSpaces ) {
81- text = text . trim ( ) ;
79+ // If the text is empty or contains only spaces...
80+ if ( text . trim ( ) . length === 0 ) {
81+ if ( settingValues . trimSurroundingSpaces ) {
82+ // ...And trimSurroundingSpaces is enabled, return an empty string
83+ return '' ;
84+ } else {
85+ // ...Otherwise, return the original text
86+ return text ;
87+ }
8288 }
8389
84- if ( text . length === 0 ) return text ;
90+ let processedText = text ;
91+ if ( settingValues . trimSurroundingSpaces ) {
92+ processedText = text . trim ( ) ;
93+ }
8594
8695 // Split text into individual lines for processing
87- const lines = text . split ( '\n' ) ;
96+ const lines = processedText . split ( '\n' ) ;
8897 const formattedLines = [ ] ;
8998
9099 for ( const line of lines ) {
You can’t perform that action at this time.
0 commit comments