@@ -35,9 +35,10 @@ local function get_contents (buffer)
3535 return table.concat (lines )
3636end
3737
38- local function highlight (buffer , namespace , firstline )
38+ local function highlight (buffer , namespace , firstline , lastline )
3939 local contents = get_contents (buffer )
4040 local firstbyte = call_function (" line2byte" , { firstline })
41+ local lastbyte = call_function (" line2byte" , { lastline + 1 }) - 1
4142 local events = rust .get_offsets (contents , firstbyte )
4243 for _ , event in ipairs (events ) do
4344 repeat -- Allow continue in for loop
6768function commonmarker :attach (buffer )
6869 if self ._attachments [buffer ] then return end
6970 self ._attachments [buffer ] = true
70- highlight (buffer , self ._namespace , 0 )
71+ highlight (buffer , self ._namespace , 0 , - 1 )
7172 buf_attach (buffer , false , {
72- on_lines = function (_ , _ , _ , firstline , _ , _ )
73- buf_clear_namespace (buffer , self ._namespace , firstline , - 1 )
73+ on_lines = function (_ , _ , _ , firstline , lastline , _ )
74+ buf_clear_namespace (buffer , self ._namespace , firstline , lastline )
7475 -- Returning true here detaches, we thought we should have been already
7576 if not self ._attachments [buffer ] then return true end
76- highlight (buffer , self ._namespace , firstline )
77+ highlight (buffer , self ._namespace , firstline , lastline )
7778 end ,
7879 on_detach = function (_ )
7980 self ._attachments [buffer ] = nil
0 commit comments