Open anthony-S93 opened 8 months ago
This is a side effect of a trick I'm using when getting the scope. I convert the cursor position to a range from the beginning of the line, to the cursor.
I do this to avoid weird single line scopes. In most languages this works, but in Python indentation matters, so it's not quite right.
This would be pretty tricky to fix without breaking other cases worse. So I think I will not look into this.
But PRs are always welcome.
This isn't an issue per se; I'm asking out of curiosity more than anything else.
The behavior can be demonstrated using the following sample code (refer to the attached video):
Note that both
class_definition
andfunction_definition
are listed inscope.include.python
https://github.com/lukas-reineke/indent-blankline.nvim/assets/69449791/d18c2175-7a77-4a64-bd42-7e38ba1a405b
Which seems a bit strange to me because upon inspecting the highlight groups using
:InspectTree
, I didn't see any difference in the way the twofunction_definition
s are parsed other than the fact that one is nested in a block while the other is at the top level.As you can see, in both
function_definition
s, the start and end positions listed by the parser are accurate. Given their similarities, I was wondering why the plugin treats both cases differently. According to the parser, the nested function begins at position[10:5]
; but since the indent line is shown starting from one line below the declaration, the highlighting of the indent line will not take place until the cursor has gone past the first newline in the scope. This behavior is sensible albeit inconsistent with the case where the declaration is at the top-level of the source file. Fortop_level_function()
, the highlighting takes place as soon as the cursor enters the line containing the declaration.