From b94fab30706f4cdba15fe4c35c9394153d4cd7ff Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Thu, 26 Sep 2019 15:08:56 +0100 Subject: [PATCH] Use matchaddpos() instead of text properties matchaddpos() has better backward compatibility than text properties. I only used text properties inside Vim popups because I did not think there was a way to use matchaddpos(), but then I found a way. --- autoload/gitgutter/hunk.vim | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 6225ff3..ffde78b 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -1,10 +1,5 @@ let s:winid = 0 -if exists('*prop_type_add') - call prop_type_add('gitgutter_add_intra_line', {'highlight': 'GitGutterAddIntraLine', 'combine': 1}) - call prop_type_add('gitgutter_delete_intra_line', {'highlight': 'GitGutterDeleteIntraLine', 'combine': 1}) -endif - function! gitgutter#hunk#set_hunks(bufnr, hunks) abort call gitgutter#utility#setbufvar(a:bufnr, 'hunks', a:hunks) call s:reset_summary(a:bufnr) @@ -476,12 +471,10 @@ function! s:populate_hunk_preview_window(header, body) if exists('*popup_create') call popup_settext(s:winid, a:body) - if has('patch-8.1.2071') - for region in gitgutter#diff_highlight#process(a:body) - let type = region[1] == '+' ? 'gitgutter_add_intra_line' : 'gitgutter_delete_intra_line' - call prop_add(region[0], region[2], {'bufnr': winbufnr(s:winid), 'type': type, 'end_col': region[3]+1}) - endfor - endif + for region in gitgutter#diff_highlight#process(a:body) + let group = region[1] == '+' ? 'GitGutterAddIntraLine' : 'GitGutterDeleteIntraLine' + call win_execute(s:winid, "call matchaddpos('".group."', [[".region[0].", ".region[2].", ".(region[3]-region[2]+1)."]])") + endfor endif else