File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -232,17 +232,18 @@ fn create_wrapping_options<'a>(
232232 } else if atty:: is ( atty:: Stream :: Stdout ) {
233233 let width = crossterm:: terminal:: size ( )
234234 . map_err ( |err| err. to_string ( ) ) ?
235- . 0 ;
236- let width = if width as usize > graph_width {
237- width as usize - graph_width
235+ . 0 as usize ;
236+ let text_width = width. saturating_sub ( graph_width) ;
237+ if text_width < 40 {
238+ // If too little space left for text, do not wrap at all
239+ None
238240 } else {
239- 1
240- } ;
241- Some (
242- textwrap:: Options :: new ( width)
243- . initial_indent ( indent1)
244- . subsequent_indent ( indent2) ,
245- )
241+ Some (
242+ textwrap:: Options :: new ( text_width)
243+ . initial_indent ( indent1)
244+ . subsequent_indent ( indent2) ,
245+ )
246+ }
246247 } else {
247248 None
248249 } ;
You can’t perform that action at this time.
0 commit comments