From ed51cb2599fce1be5d71806bc513b5da9ced0497 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 18 Jul 2017 15:57:08 +0200 Subject: [PATCH] Signs: do not exceed two cells This is only enforced for dynamically created signs, namely g:signify_sign_delete and g:signify_sign_changedelete, if g:signify_sign_show_count is on. References https://github.com/mhinz/vim-signify/issues/105 --- autoload/sy/highlight.vim | 7 +++++-- autoload/sy/sign.vim | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/autoload/sy/highlight.vim b/autoload/sy/highlight.vim index 2661a35..2ebe507 100644 --- a/autoload/sy/highlight.vim +++ b/autoload/sy/highlight.vim @@ -14,7 +14,8 @@ else let s:sign_change = ' ' let s:sign_changedelete = ' ' endif -let s:sign_show_count = get(g:, 'signify_sign_show_count', 1) + +let s:sign_show_count = get(g:, 'signify_sign_show_count', 1) " Function: #setup {{{1 function! sy#highlight#setup() abort @@ -60,7 +61,9 @@ function! sy#highlight#line_disable() abort execute 'sign define SignifyRemoveFirstLine text='. s:sign_delete_first_line 'texthl=SignifySignDeleteFirstLine linehl=' if s:sign_show_count - let s:sign_changedelete = substitute(s:sign_changedelete, '^.\zs.*', '', '') + while strwidth(s:sign_changedelete) > 1 + let s:sign_changedelete = substitute(s:sign_changedelete, '.', '', '') + endwhile for n in range(1, 9) execute 'sign define SignifyChangeDelete'. n 'text='. s:sign_changedelete . n 'texthl=SignifySignChangeDelete linehl=' endfor diff --git a/autoload/sy/sign.vim b/autoload/sy/sign.vim index 23ccdbe..a8f49e2 100644 --- a/autoload/sy/sign.vim +++ b/autoload/sy/sign.vim @@ -96,11 +96,10 @@ function! sy#sign#process_diff(sy, vcs, diff) abort if new_line == 0 call add(ids, s:add_sign(a:sy, 1, 'SignifyRemoveFirstLine')) elseif s:sign_show_count - if old_count <= 99 - let text = substitute(s:sign_delete . old_count, '.*\ze..$', '', '') - else - let text = s:sign_delete .'>' - endif + let text = s:sign_delete . (old_count <= 99 ? old_count : '>') + while strwidth(text) > 2 + let text = substitute(text, '.', '', '') + endwhile call add(ids, s:add_sign(a:sy, new_line, 'SignifyDelete'. old_count, text)) else call add(ids, s:add_sign(a:sy, new_line, 'SignifyDeleteMore', s:sign_delete))