diff --git a/CHANGELOG.md b/CHANGELOG.md index 10eaea2..9e6ae3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lua/outline/providers/markdown.lua b/lua/outline/providers/markdown.lua index f4a0d2d..876b331 100644 --- a/lua/outline/providers/markdown.lua +++ b/lua/outline/providers/markdown.lua @@ -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 diff --git a/lua/outline/providers/norg.lua b/lua/outline/providers/norg.lua index 1de1ee8..451e8cd 100644 --- a/lua/outline/providers/norg.lua +++ b/lua/outline/providers/norg.lua @@ -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 },