fix(markdown): Don't include next heading in previous heading's range
Somehow marksman also does this? As for treesitter (norg) it may be because treesitter includes the newline and the next line indent until the next heading, so the line of the next heading is included in the range of the previous heading. We manually -1 on the range end line to fix it.
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
- A built-in provider for `norg` files that displays headings in the outline is now
|
||||
provided. This requires `norg` parser to be installed for treesitter
|
||||
- Outline.nvim now supports per-tabpage outlines
|
||||
([#37](https://github.com/hedyhli/outline.nvim/issues/37))
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -99,6 +100,10 @@
|
||||
([#19](https://github.com/hedyhli/outline.nvim/issues/19))
|
||||
- Fixed display of JSX Fragments due to recent update from `javascript` TS
|
||||
parser
|
||||
- Markdown parser included the next heading when setting the end range for
|
||||
previous heading. So when cursor was on the next heading, the previous heading
|
||||
would also be highlighted in the outline. This is now fixed, but marksman LSP
|
||||
would still do this. A "fix" is to add marksman into lsp client blacklist.
|
||||
|
||||
### Performance
|
||||
|
||||
|
||||
@@ -80,8 +80,11 @@ function M.handle_markdown()
|
||||
|
||||
for i = depth, max_level do
|
||||
if level_symbols[i] ~= nil then
|
||||
level_symbols[i].selectionRange['end'].line = line - 1
|
||||
level_symbols[i].range['end'].line = line - 1
|
||||
-- -1 for 0-index, -1 to not include current line
|
||||
-- TODO: This fix can be removed when we let highlight_hovered_item
|
||||
-- account for current column position in addition to the line
|
||||
level_symbols[i].selectionRange['end'].line = line - 2
|
||||
level_symbols[i].range['end'].line = line - 2
|
||||
level_symbols[i] = nil
|
||||
end
|
||||
end
|
||||
@@ -106,13 +109,6 @@ function M.handle_markdown()
|
||||
::nextline::
|
||||
end
|
||||
|
||||
for i = 2, max_level do
|
||||
if level_symbols[i] ~= nil then
|
||||
level_symbols[i].selectionRange['end'].line = #lines
|
||||
level_symbols[i].range['end'].line = #lines
|
||||
end
|
||||
end
|
||||
|
||||
return level_symbols[1].children
|
||||
end
|
||||
|
||||
|
||||
@@ -102,6 +102,11 @@ function M.request_symbols(callback, opts)
|
||||
local current = {
|
||||
kind = 15,
|
||||
name = title,
|
||||
-- Treesitter includes the last newline in the end range which spans
|
||||
-- until the next heading, so we -1
|
||||
-- TODO: This fix can be removed when we let highlight_hovered_item
|
||||
-- account for current column position in addition to the line.
|
||||
-- FIXME: By the way the end character should be the EOL
|
||||
selectionRange = {
|
||||
start = { character = col1, line = row1 },
|
||||
['end'] = { character = col2, line = row2 - 1 },
|
||||
|
||||
Reference in New Issue
Block a user