tree-sitter / tree-sitter-python

Python grammar for tree-sitter
MIT License
372 stars 138 forks source link

WIP: Remove redundant indentation check of comment #243

Closed llllvvuu closed 1 year ago

llllvvuu commented 1 year ago

This handles the following case missed by #242 (was still O(n^2) in number of comment lines since DEDENT is valid to lookahead to on every line)

class Foo:
    def foo():
        print("bar")
    # xxx
    # xxx
    def bar():
        print("foo")

(big version)

but it does not handle the following case:

class Foo:
    def foo():
        print("bar")
    # xxx
    # xxx
        print("foo")

since no dedent token is ever generated and therefore there is nothing to "cache".

It also does not handle the following case (but #244 does):

class Foo:
    def foo():
        print("bar")
        # xxx
        # xxx
        print("foo")
lucario387 commented 1 year ago

but it does not handle the following case:

Whatever for that case :smile:, I don't think there's a Python programmer that codes with that style

llllvvuu commented 1 year ago

closing for now in favor of #244 (also I think a found an edge case which is broken here in #243)