File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,17 +164,23 @@ component singleton {
164164 return newContent
165165 }
166166
167- var existingContent = fileRead ( filePath )
167+ // Read existing content and locate markers
168+ var existingContent = fileRead ( filePath ).trim ()
168169 var startPos = findNoCase ( startMarker , existingContent )
169170 var endPos = findNoCase ( endMarker , existingContent )
170171
172+ // If existing content is empty or markers are not properly found, return new content as-is
173+ if ( ! len ( existingContent ) ) {
174+ return newContent
175+ }
176+
171177 // Old-format file (no marker pair) — write fresh content
172178 if ( ! startPos || ! endPos || endPos <= startPos ) {
173179 return newContent
174180 }
175181
176182 // Preserve user-authored content around managed section
177- var userContentBeforeManaged = left ( existingContent , startPos - 1 )
183+ var userContentBeforeManaged = startPos > 1 ? left ( existingContent , startPos - 1 ) : " "
178184 var userStartPos = endPos + len ( endMarker )
179185 var userContentAfterManaged = mid (
180186 existingContent ,
You can’t perform that action at this time.
0 commit comments