Skip to content

Commit e91b042

Browse files
fix: use virtual text for heading border at start & end
## Details Issue: #187 When using smoothscrolling and textwrap on long lines pasting text would cause a visual bug where text was duplicated. This ended up being because when a heading is the last line in a file we attempt to use an overlay to put the border below it. I assumed I had written the logic to use virtual text on both ends of a document however it turns out virtual text was only used at the top most line as a special case and not at the bottom. The fix for this bug is then straightforward and we now validate a line exists and is empty rather than not existing meaning empty. While this specific issue is fixed it does seem there are generally some issues with smoothscrolling, textwrap, and virtual lines.
1 parent efb4c48 commit e91b042

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lua/render-markdown/core/context.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ local util = require('render-markdown.core.util')
1212
---@field private conceal? table<integer, [integer, integer][]>
1313
---@field private links table<integer, [integer, integer, integer][]>
1414
---@field private window_width? integer
15-
---@field last_heading integer
15+
---@field last_heading? integer
1616
local Context = {}
1717
Context.__index = Context
1818

@@ -37,7 +37,7 @@ function Context.new(buf, win, offset)
3737
self.conceal = nil
3838
self.links = {}
3939
self.window_width = nil
40-
self.last_heading = -1
40+
self.last_heading = nil
4141
return self
4242
end
4343

lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local state = require('render-markdown.state')
44
local M = {}
55

66
---@private
7-
M.version = '7.2.8'
7+
M.version = '7.2.9'
88

99
function M.check()
1010
M.start('version')

lua/render-markdown/render/heading.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ end
246246
---@param position 'above'|'below'
247247
---@return boolean
248248
function Render:empty_line(position)
249-
return str.width(self.info:line(position, 1)) == 0
249+
local line = self.info:line(position, 1)
250+
return line ~= nil and str.width(line) == 0
250251
end
251252

252253
---@private

0 commit comments

Comments
 (0)