Skip to content

Commit 9d184e7

Browse files
author
skywind3000
committed
1. refactor navigator#charname#mapname() to prevent infinite loop
2. remove verbose message when cleaning the buffer content.
1 parent 723cdbd commit 9d184e7

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

autoload/navigator/charname.vim

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,30 +203,33 @@ endfunc
203203
"----------------------------------------------------------------------
204204
function! navigator#charname#mapname(content) abort
205205
let content = a:content
206-
let xcount = 1000
206+
let output = []
207+
let pos = 0
207208
while 1
208-
let p1 = stridx(content, '<')
209+
let p1 = stridx(content, '<', pos)
209210
if p1 < 0
211+
call add(output, strpart(content, pos))
210212
break
211213
endif
212214
let p2 = stridx(content, '>', p1)
213215
if p2 < 0
216+
call add(output, strpart(content, pos))
214217
break
215218
endif
216219
let text = strpart(content, p1 + 1, p2 - p1 - 1)
217220
let mark = '<' . text . '>'
218-
try
219-
let replace = eval('"\' . mark . '"')
220-
catch
221-
break
222-
endtry
223-
let content = s:replace(content, mark, replace)
224-
let xcount -= 1
225-
if xcount <= 0
226-
break
221+
let replace = mark
222+
if len(mark) > 2
223+
try
224+
let replace = eval('"\' . mark . '"')
225+
catch
226+
endtry
227227
endif
228+
call add(output, strpart(content, pos, p1 - pos))
229+
call add(output, replace)
230+
let pos = p2 + 1
228231
endwhile
229-
return content
232+
return join(output, '')
230233
endfunc
231234

232235

autoload/navigator/utils.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function! navigator#utils#create_buffer() abort
6767
call setbufvar(bid, 'noswapfile', 1)
6868
endif
6969
call setbufvar(bid, '&modifiable', 1)
70-
call deletebufline(bid, 1, '$')
70+
silent call deletebufline(bid, 1, '$')
7171
call setbufvar(bid, '&modified', 0)
7272
call setbufvar(bid, '&filetype', '')
7373
return bid

0 commit comments

Comments
 (0)