@@ -374,6 +374,40 @@ function! s:postfix(request) abort
374
374
return ' (' . a: request .handler.' /' .(! empty (pid) ? pid : ' ?' ) . ' )'
375
375
endfunction
376
376
377
+ function ! s: echo_truncated (left , right ) abort
378
+ if exists (' v:echospace' )
379
+ let max_len = (&cmdheight - 1 ) * &columns + v: echospace
380
+ else
381
+ let max_len = &cmdheight * &columns - 1
382
+ let last_has_status = (&laststatus == 2 || (&laststatus == 1 && winnr (' $' ) != 1 ))
383
+
384
+ if &ruler && ! last_has_status
385
+ if empty (&rulerformat )
386
+ " Default ruler is 17 chars wide.
387
+ let max_len -= 17
388
+ elseif exists (' g:rulerwidth' )
389
+ " User specified width of custom ruler.
390
+ let max_len -= g: rulerwidth
391
+ else
392
+ " Don't know width of custom ruler, make a conservative guess.
393
+ let max_len -= &columns / 2
394
+ endif
395
+ let max_len -= 1
396
+ endif
397
+ if &showcmd
398
+ let max_len -= 10
399
+ if ! &ruler || last_has_status
400
+ let max_len -= 1
401
+ endif
402
+ endif
403
+ endif
404
+ let msg = a: left . a: right
405
+ if len (substitute (msg, ' .' , ' .' , ' g' )) > max_len
406
+ let msg = a: left . ' <' . matchstr (a: right , ' \v.{' .(max_len - len (substitute (a: left , ' .' , ' .' , ' g' )) - 1 ).' }$' )
407
+ endif
408
+ echo msg
409
+ endfunction
410
+
377
411
function ! s: dispatch (request) abort
378
412
for handler in g: dispatch_handlers
379
413
if get (g: , ' dispatch_no_' . handler . ' _' . get (a: request , ' action' )) ||
@@ -388,41 +422,8 @@ function! s:dispatch(request) abort
388
422
redraw
389
423
let msg = ' :!'
390
424
let suffix = s: postfix (a: request )
391
- let suffix_len = len (substitute (suffix, ' .' , ' .' , ' g' ))
392
- let max_cmd_len = (&cmdheight * &columns ) - 2 - suffix_len - 2
393
-
394
- if has (' cmdline_info' )
395
- let last_has_status = (&laststatus == 2 || (&laststatus == 1 && winnr (' $' ) != 1 ))
396
-
397
- if &ruler && ! last_has_status
398
- if empty (&rulerformat )
399
- " Default ruler is 17 chars wide.
400
- let max_cmd_len -= 17
401
- elseif exists (' g:rulerwidth' )
402
- " User specified width of custom ruler.
403
- let max_cmd_len -= g: rulerwidth
404
- else
405
- " Don't know width of custom ruler, make a conservative guess.
406
- let max_cmd_len -= &columns / 2
407
- endif
408
- let max_cmd_len -= 1
409
- endif
410
- if &showcmd
411
- let max_cmd_len -= 10
412
- if ! &ruler || last_has_status
413
- let max_cmd_len -= 1
414
- endif
415
- endif
416
- endif
417
- let cmd = a: request .expanded
418
- let cmd_len = len (substitute (cmd, ' .' , ' .' , ' g' ))
419
- if cmd_len > max_cmd_len
420
- let msg .= ' <' . matchstr (cmd, ' \v.{' .(max_cmd_len - 1 ).' }$' )
421
- else
422
- let msg .= cmd
423
- endif
424
- let msg .= ' ' .suffix
425
- echo msg
425
+ let cmd = a: request .expanded . ' ' . suffix
426
+ call s: echo_truncated (' :!' , a: request .expanded . ' ' . s: postfix (a: request ))
426
427
return response
427
428
endif
428
429
endfor
0 commit comments