@@ -141,10 +141,11 @@ export def IsURL(link: string): bool
141141 return false
142142enddef
143143
144- def LinksPopupCallback (match_id: number ,
145- type : string ,
144+ def LinksPopupCallback (type : string ,
146145 popup_id: number ,
147- idx: number )
146+ idx: number ,
147+ match_id: number
148+ )
148149 if idx > 0
149150 const selection = getbufline (winbufnr (popup_id), idx)[0 ]
150151 var link_id = -1
@@ -302,13 +303,15 @@ export def PopupFilter(id: number,
302303 key : string ,
303304 slave_id: number ,
304305 results: list <string> ,
305- match_id: number ,
306+ match_id: number = -1 ,
306307 ): bool
307308
308309 var maxheight = popup_getoptions (slave_id).maxheight
309310
310311 if key == " \<esc> "
311- matchdelete (match_id)
312+ if match_id != -1
313+ matchdelete (match_id)
314+ endif
312315 ClosePopups ()
313316 return true
314317 endif
@@ -429,7 +432,11 @@ export def PopupFilter(id: number,
429432 return true
430433enddef
431434
432- export def ShowPromptPopup (slave_id: number , links: list <string> , title : string , match_id: number )
435+ export def ShowPromptPopup (slave_id: number ,
436+ links: list <string> ,
437+ title : string ,
438+ match_id: number = -1
439+ )
433440 # This could be called by other scripts and its id may be undefined.
434441 InitScriptLocalVars ()
435442 # This is the UI thing
@@ -491,7 +498,7 @@ export def CreateLink(type: string = '')
491498 redraw
492499
493500 links_popup_opts.callback =
494- (popup_id, idx) = > LinksPopupCallback (match_id, type , popup_id, idx)
501+ (popup_id, idx) = > LinksPopupCallback (type , popup_id, idx, match_id )
495502
496503 var links = values (b: markdown_extras_links )- >insert (" Create new link" )
497504 var popup_height = min ([len (links), (&lines * 2 ) / 3 ])
0 commit comments