File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -808,9 +808,17 @@ export function mergeAgentsFiles(agentsFiles: string[]): string {
808808 result . push ( content ) ;
809809
810810 if ( nextContent ) {
811- const currentLines = content . split ( '\n' ) ;
812- const lastLine = currentLines [ currentLines . length - 1 ] ;
813- const nextFirstLine = nextContent . split ( '\n' ) [ 0 ] ;
811+ const lastNewLineIndex = content . lastIndexOf ( '\n' ) ;
812+ const lastLine =
813+ lastNewLineIndex === - 1
814+ ? content
815+ : content . substring ( lastNewLineIndex + 1 ) ;
816+
817+ const firstNewLineIndex = nextContent . indexOf ( '\n' ) ;
818+ const nextFirstLine =
819+ firstNewLineIndex === - 1
820+ ? nextContent
821+ : nextContent . substring ( 0 , firstNewLineIndex ) ;
814822
815823 // If both blocks are part of an unordered list (starting with '- '),
816824 // skip the newline to merge them.
You can’t perform that action at this time.
0 commit comments