File tree Expand file tree Collapse file tree 3 files changed +38
-20
lines changed Expand file tree Collapse file tree 3 files changed +38
-20
lines changed Original file line number Diff line number Diff line change @@ -88,14 +88,7 @@ endfunction
8888
8989" s:get_lines {{{1
9090function ! s: get_lines () abort
91- let signlist = sy#util#execute (' sign place buffer=' . b: sy .buffer )
92-
93- let lines = []
94- for line in split (signlist, ' \n' )[2 :]
95- call insert (lines , matchlist (line , ' \v^\s+line\=(\d+)' )[1 ], 0 )
96- endfor
97-
98- return reverse (lines )
91+ return map (sy#util#get_signs (b: sy .buffer ), {_, val - > val.lnum})
9992endfunction
10093
10194" s:get_levels {{{1
Original file line number Diff line number Diff line change @@ -28,24 +28,19 @@ function! sy#sign#get_current_signs(sy) abort
2828 let a: sy .internal = {}
2929 let a: sy .external = {}
3030
31- let signlist = sy#util#execute ( ' sign place buffer= ' . a: sy .buffer )
31+ let signlist = sy#util#get_signs ( a: sy .buffer )
3232
33- for signline in split (signlist, ' \n' )[2 :]
34- let tokens = matchlist (signline, ' \v^\s+\S+\=(\d+)\s+\S+\=(\d+)\s+\S+\=(.*)$' )
35- let line = str2nr (tokens[1 ])
36- let id = str2nr (tokens[2 ])
37- let type = tokens[3 ]
38-
39- if type = ~# ' ^Signify'
33+ for sign in signlist
34+ if sign .name = ~# ' ^Signify'
4035 " Handle ambiguous signs. Assume you have signs on line 3 and 4.
4136 " Removing line 3 would lead to the second sign to be shifted up
4237 " to line 3. Now there are still 2 signs, both one line 3.
43- if has_key (a: sy .internal, line )
44- execute ' sign unplace' a: sy .internal[line ].id ' buffer=' .a: sy .buffer
38+ if has_key (a: sy .internal, sign .lnum )
39+ execute ' sign unplace' a: sy .internal[sign .lnum ].id ' buffer=' .a: sy .buffer
4540 endif
46- let a: sy .internal[line ] = { ' type' : type , ' id' : id }
41+ let a: sy .internal[sign .lnum ] = { ' type' : sign .name , ' id' : sign . id }
4742 else
48- let a: sy .external[line ] = id
43+ let a: sy .external[sign .lnum ] = sign . id
4944 endif
5045 endfor
5146endfunction
Original file line number Diff line number Diff line change @@ -229,3 +229,33 @@ function! s:offset() abort
229229 endif
230230 return offset
231231endfunction
232+
233+ " #get_signs {{{1
234+ if exists (' *sign_getplaced' )
235+ function ! sy#util#get_signs (bufnr )
236+ return sign_getplaced (a: bufnr )[0 ].signs
237+ endfunction
238+ else
239+ function ! sy#util#get_signs (bufnr )
240+ let buf = bufnr (a: bufnr )
241+ let signs = []
242+
243+ let signlist = execute (' sign place buffer=' . buf )
244+ for signline in split (signlist, ' \n' )[2 :]
245+ let tokens = matchlist (signline, ' \v^\s+\S+\=(\d+)\s+\S+\=(\d+)\s+\S+\=(.*)\s+\S+\=(\d+)$' )
246+ let line = str2nr (tokens[1 ])
247+ let id = str2nr (tokens[2 ])
248+ let name = tokens[3 ]
249+ let priority = str2nr (tokens[4 ])
250+ call add (signs, {
251+ \ ' lnum' : line ,
252+ \ ' id' : id,
253+ \ ' name' : name,
254+ \ ' priority' : priority,
255+ \ ' group' : ' '
256+ \ })
257+ endfor
258+
259+ return signs
260+ endfunction
261+ endif
You can’t perform that action at this time.
0 commit comments