@@ -208,11 +208,13 @@ end
208
208
--- @param buf integer the buf number
209
209
--- @param lines table the lines to append
210
210
--- @param highlights ? table the highlights to apply
211
- local function refresh_outline (buf , lines , highlights )
211
+ --- @param outline_uri string the uri of the outline
212
+ local function refresh_outline (buf , lines , highlights , outline_uri )
212
213
vim .bo [buf ].modifiable = true
213
214
local ok = pcall (api .nvim_buf_set_lines , buf , 0 , - 1 , false , lines )
214
215
if not ok then return end
215
216
vim .bo [buf ].modifiable = false
217
+ vim .b [buf ].outline_uri = outline_uri
216
218
if highlights then ui .add_highlights (state .outline_buf , highlights ) end
217
219
end
218
220
@@ -282,9 +284,9 @@ local function setup_autocommands()
282
284
pattern = utils .events .OUTLINE_CHANGED ,
283
285
callback = function ()
284
286
if not utils .buf_valid (state .outline_buf ) then return end
285
- local ok , lines , highlights = get_outline_content ()
286
- if not ok or not lines then return end
287
- refresh_outline (state .outline_buf , lines , highlights )
287
+ local ok , lines , highlights , outline = get_outline_content ()
288
+ if not ok or not lines or not outline then return end
289
+ refresh_outline (state .outline_buf , lines , highlights , outline . uri )
288
290
end ,
289
291
})
290
292
autocmd ({ " CursorHold" }, {
358
360
function M .open (opts )
359
361
opts = opts or {}
360
362
local ok , lines , highlights , outline = get_outline_content ()
361
- if not ok or not lines then
363
+ if not ok or not lines or not outline then
362
364
ui .notify (" Sorry! There is no outline for this file" )
363
365
return
364
366
end
@@ -369,12 +371,14 @@ function M.open(opts)
369
371
open_cmd = options .open_cmd ,
370
372
filetype = outline_filetype ,
371
373
filename = outline_filename ,
372
- }, function (buf , win ) setup_outline_window (buf , win , lines , highlights , opts .go_back ) end )
374
+ focus_on_open = true ,
375
+ }, function (buf , win )
376
+ setup_outline_window (buf , win , lines , highlights , opts .go_back )
377
+ vim .b [buf ].outline_uri = outline .uri
378
+ end )
373
379
else
374
- refresh_outline (state .outline_buf , lines , highlights )
380
+ refresh_outline (state .outline_buf , lines , highlights , outline . uri )
375
381
end
376
- if not outline then return end
377
- vim .b .outline_uri = outline .uri
378
382
if opts .go_back and api .nvim_win_is_valid (parent_win ) then
379
383
api .nvim_set_current_win (parent_win )
380
384
end
0 commit comments