File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
implement-shell-tools/cat Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -20,17 +20,15 @@ const paddingWidth = 6; // width for line number padding
2020
2121// Helper function to format a line with numbering
2222function formatLine ( line , lineNumber , numberAll , numberNonBlank ) {
23+ const numbered = `${ lineNumber . toString ( ) . padStart ( paddingWidth ) } ${ line } ` ;
2324 if ( numberAll ) {
24- return ` ${ lineNumber . toString ( ) . padStart ( paddingWidth ) } ${ line } ` ;
25+ return numbered
2526 }
26- if ( numberNonBlank ) {
27- if ( line . trim ( ) === "" ) {
28- return line ; // blank line, no number
29- }
30- return `${ lineNumber . toString ( ) . padStart ( paddingWidth ) } ${ line } ` ;
31- }
32- return line ; // no numbering
33- }
27+ if ( numberNonBlank ) {
28+ return line . trim ( ) === "" ? line : numbered ;
29+ }
30+ return line ;
31+ }
3432const options = program . opts ( ) ;
3533const files = program . args ; // Array of file paths passed as arguments
3634
You can’t perform that action at this time.
0 commit comments