Skip to content

Commit 6e5da68

Browse files
committed
fix(render): do not show context when within window
1 parent 153a076 commit 6e5da68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/treesitter-context/context.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,13 @@ function M.get(bufnr, winid)
361361
for _, parent in ipairs(parents) do
362362
local parent_start_row = parent:range()
363363

364+
local num_context_lines = math.min(max_lines, contexts_height)
365+
364366
-- NOTE: this avoids covering up context by separator line
365-
local separator_offset = config.separator and 1 or 0
367+
-- but is only needed when context is nontrivial of course
368+
local separator_offset = (num_context_lines > 0 and config.separator) and 1 or 0
366369

367-
local contexts_end_row = top_row + separator_offset + math.min(max_lines, contexts_height)
370+
local contexts_end_row = top_row + separator_offset + num_context_lines
368371

369372
-- Only process the parent if it is not in view.
370373
if parent_start_row < contexts_end_row then

0 commit comments

Comments
 (0)