File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -266,7 +266,9 @@ export class Completion implements CompletionInstance {
266
266
const desc = descs [ key ] ?? descFromAlias ?? '' ;
267
267
completions . push (
268
268
dashes +
269
- `${ key . replace ( / : / g, '\\:' ) } :${ desc . replace ( '__yargsString__:' , '' ) } `
269
+ `${ key . replace ( / : / g, '\\:' ) } :${ desc
270
+ . replace ( '__yargsString__:' , '' )
271
+ . replace ( / ( \r \n | \n | \r ) / gm, ' ' ) } `
270
272
) ;
271
273
}
272
274
}
Original file line number Diff line number Diff line change @@ -1077,6 +1077,23 @@ describe('Completion', () => {
1077
1077
r . logs . should . include ( '-B:Bar option' ) ;
1078
1078
} ) ;
1079
1079
1080
+ it ( 'completes options with line break' , ( ) => {
1081
+ process . env . SHELL = '/bin/zsh' ;
1082
+ const r = checkUsage (
1083
+ ( ) =>
1084
+ yargs ( [ './completion' , '--get-yargs-completions' , '-' ] )
1085
+ . options ( {
1086
+ foo : { describe : 'Foo option\nFoo option' , type : 'string' } ,
1087
+ } )
1088
+ . help ( false )
1089
+ . version ( false )
1090
+ . completion ( ) . argv
1091
+ ) ;
1092
+
1093
+ r . logs . should . have . length ( 1 ) ;
1094
+ r . logs . should . include ( '--foo:Foo option Foo option' ) ;
1095
+ } ) ;
1096
+
1080
1097
it ( 'replaces application variable with $0 in script' , ( ) => {
1081
1098
process . env . SHELL = '/bin/zsh' ;
1082
1099
const r = checkUsage ( ( ) => yargs ( [ ] ) . showCompletionScript ( ) , [ 'ndm' ] ) ;
You can’t perform that action at this time.
0 commit comments