@@ -209,14 +209,19 @@ function unknownBlock(index: SourceIndex, query: string): CliUsageError {
209209 } )
210210}
211211
212- /** A wiring statement's text on one line, so a fan-out the printer wrapped reads whole. */
212+ /**
213+ * A wiring statement's text on one line, so a fan-out the printer wrapped reads whole. Only the
214+ * line breaks are rewritten, so a raw handle's text is printed as written.
215+ */
213216function statementText ( index : SourceIndex , span : SourceSpan ) : string {
214217 const lines = index . linesOf ( span . file ) ?. lines . slice ( span . line - 1 , span . endLine ) ?? [ ]
215218 return lines
216219 . map ( ( line ) => line . trim ( ) )
217- . join ( ' ' )
218- . replace ( / \( \s + / g, '(' )
219- . replace ( / , ? \s + \) / g, ')' )
220+ . reduce ( ( joined , line ) => {
221+ if ( joined === '' ) return line
222+ if ( line . startsWith ( ')' ) ) return `${ joined . replace ( / , $ / , '' ) } ${ line } `
223+ return joined . endsWith ( '(' ) ? `${ joined } ${ line } ` : `${ joined } ${ line } `
224+ } , '' )
220225}
221226
222227function describeBlock (
@@ -296,7 +301,9 @@ export function attachWorkflowSourceFind(source: Command): void {
296301 await assertSourceDirKind ( options . dir , 'workflow' )
297302 const catalog = await lookupCatalog ( options . dir , profile )
298303 const { compiled, files } = await compileWorkflowDir ( options . dir , catalog )
299- if ( query . trim ( ) === '' ) throw new CliUsageError ( 'Name a block.' , { code : 'BLOCK_UNKNOWN' } )
304+ if ( normalizeWorkflowBlockName ( query ) === '' ) {
305+ throw new CliUsageError ( 'Name a block.' , { code : 'BLOCK_UNKNOWN' } )
306+ }
300307 const index = new SourceIndex ( compiled , files )
301308 const keys = matchBlocks ( index , query )
302309 if ( keys . length === 0 ) throw unknownBlock ( index , query )
0 commit comments