@@ -494,6 +494,7 @@ M.display_chat_agent = function(buf, file_name)
494
494
})
495
495
end
496
496
497
+ M ._prepared_bufs = {}
497
498
M .prep_chat = function (buf , file_name )
498
499
if M .not_chat (buf , file_name ) then
499
500
return
@@ -503,6 +504,13 @@ M.prep_chat = function(buf, file_name)
503
504
return
504
505
end
505
506
507
+ M .refresh_state ({ last_chat = file_name })
508
+ if M ._prepared_bufs [buf ] then
509
+ M .logger .debug (" buffer already prepared: " .. buf )
510
+ return
511
+ end
512
+ M ._prepared_bufs [buf ] = true
513
+
506
514
M .prep_md (buf )
507
515
508
516
if M .config .chat_prompt_buf_type then
@@ -559,8 +567,6 @@ M.prep_chat = function(buf, file_name)
559
567
vim .fn .matchadd (" Conceal" , [[ ^- role: .\{64,64\}\zs.*\ze]] , 10 , - 1 , { conceal = " …" })
560
568
vim .fn .matchadd (" Conceal" , [[ ^- role: .[^\\]*\zs\\.*\ze]] , 10 , - 1 , { conceal = " …" })
561
569
end
562
-
563
- M .refresh_state ({ last_chat = file_name })
564
570
end
565
571
566
572
M .buf_handler = function ()
@@ -1604,6 +1610,11 @@ M.prep_context = function(buf, file_name)
1604
1610
if buf ~= vim .api .nvim_get_current_buf () then
1605
1611
return
1606
1612
end
1613
+ if M ._prepared_bufs [buf ] then
1614
+ M .logger .debug (" buffer already prepared: " .. buf )
1615
+ return
1616
+ end
1617
+ M ._prepared_bufs [buf ] = true
1607
1618
1608
1619
M .prep_md (buf )
1609
1620
end
0 commit comments