You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
deftop_level_function(): # For top-level blocks, the scope is highlighted when the cursor is at the header.print("foo")
classTopLevelClass: # For top-level blocks, the scope is highlighted when the cursor is at the header.def__init__(self) ->None: # Which isn't the case for nested blocks.# For nested blocks, the scope is only highlighted when the cursor is one line past the headerself.foo="bar"
Note that both class_definition and function_definition are listed in scope.include.python
indent_blank_line_python-2023-12-16_15.47.05.mp4
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 two function_definitions 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_definitions, 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. For top_level_function(), the highlighting takes place as soon as the cursor enters the line containing the declaration.
The text was updated successfully, but these errors were encountered:
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.
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
indent_blank_line_python-2023-12-16_15.47.05.mp4
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.The text was updated successfully, but these errors were encountered: