From 304a2b9c27082b564559d95dcfb2353c241ab302 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 18 Jan 2017 16:28:35 +0100 Subject: [PATCH] Simplify sign ID handling --- autoload/sy.vim | 4 +--- autoload/sy/debug.vim | 2 +- autoload/sy/repo.vim | 5 +---- autoload/sy/sign.vim | 14 +++++++------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/autoload/sy.vim b/autoload/sy.vim index dcd8ac9..16a4ff4 100644 --- a/autoload/sy.vim +++ b/autoload/sy.vim @@ -3,7 +3,6 @@ scriptencoding utf-8 " Init: values {{{1 -let g:id_top = 0x100 let g:sy_cache = {} let s:has_doau_modeline = v:version > 703 || v:version == 703 && has('patch442') @@ -49,7 +48,7 @@ function! sy#start() abort \ 'active': 0, \ 'vcs' : 'unknown', \ 'hunks' : [], - \ 'id_top': g:id_top, + \ 'signid': 0x100, \ 'stats' : [-1, -1, -1] } if get(g:, 'signify_disable_by_default') call sy#verbose('Disabled by default.') @@ -92,7 +91,6 @@ function! sy#set_signs(diff, do_register) abort endif call sy#sign#process_diff(a:diff) - let b:sy.id_top = (g:id_top - 1) if exists('#User#Signify') execute 'doautocmd' (s:has_doau_modeline ? '' : '') 'User Signify' diff --git a/autoload/sy/debug.vim b/autoload/sy/debug.vim index 29de62a..dbf75dd 100644 --- a/autoload/sy/debug.vim +++ b/autoload/sy/debug.vim @@ -14,7 +14,7 @@ function! sy#debug#list_active_buffers() abort echo "\n". path ."\n". repeat('=', strlen(path)) - for k in ['active', 'buffer', 'vcs', 'stats', 'id_top'] + for k in ['active', 'buffer', 'vcs', 'stats', 'signid'] if k == 'stats' echo printf("%10s = %d added, %d changed, %d removed\n", \ k, diff --git a/autoload/sy/repo.vim b/autoload/sy/repo.vim index f608c5d..3747448 100644 --- a/autoload/sy/repo.vim +++ b/autoload/sy/repo.vim @@ -80,7 +80,7 @@ function! sy#repo#get_diff_start(vcs, do_register) abort execute b:sy_info.chdir b:sy_info.cwd endtry else - let diff = split(s:run(g:signify_vcs_cmds[a:vcs], b:sy_info.path), '\n') + let diff = split(s:run(a:vcs), '\n') call sy#repo#get_diff_{a:vcs}(v:shell_error, diff, a:do_register) endif endfunction @@ -88,9 +88,6 @@ endfunction " Function: s:get_diff_end {{{1 function! s:get_diff_end(found_diff, vcs, diff, do_register) abort call sy#verbose('s:get_diff_end()', a:vcs) - if !a:do_register - let b:sy.id_top = g:id_top - endif if a:found_diff let b:sy.vcs = a:vcs call sy#set_signs(a:diff, a:do_register) diff --git a/autoload/sy/sign.vim b/autoload/sy/sign.vim index 3b9150f..9bf256e 100644 --- a/autoload/sy/sign.vim +++ b/autoload/sy/sign.vim @@ -12,11 +12,11 @@ else endif let s:delete_highlight = ['', 'SignifyLineDelete'] -" Function: #get_next_id {{{1 -function! sy#sign#get_next_id() abort - let tmp = g:id_top - let g:id_top += 1 - return tmp +" Function: #id_next {{{1 +function! sy#sign#id_next() abort + let id = b:sy.signid + let b:sy.signid += 1 + return id endfunction " Function: #get_current_signs {{{1 @@ -196,7 +196,7 @@ function! sy#sign#remove_all_signs(bufnr) abort for hunk in sy.hunks for id in hunk.ids - execute 'sign unplace' id + execute 'sign unplace' id 'buffer='.a:bufnr endfor endfor @@ -220,7 +220,7 @@ function! s:add_sign(line, type, ...) abort endif if !exists('id') - let id = sy#sign#get_next_id() + let id = sy#sign#id_next() endif if a:type =~# 'SignifyDelete'