Phidica / sublime-fish

A robust Sublime Text syntax package for fish
MIT License
35 stars 2 forks source link

Lines with pipelines and comments inside functions or begin-end blocks mess up `end` highlighting #22

Closed lwolfsonkin closed 4 years ago

lwolfsonkin commented 4 years ago

It seems to be the case that end doesn't end up correctly highlighted in function/begin/etc blocks when the block's final line that isn't just a comment is a pipeline ending with a comment. I gave a bunch of examples below to show when this does and doesn't trigger.


Screen Shot 2019-11-21 at 8 31 40 PM

And the text from the screenshot:

# Example 1
begin
    cat file.txt # print file.txt
end

# Example 2
begin
    cat file.txt # print file.txt
    # comment
end

# Example 3
begin
    cat file.txt | grep 'word' # Find `word` in file.txt
end

# Example 4
begin
    cat file.txt | grep 'word' # Find `word` in file.txt

end

# Example 5
begin
    cat file.txt | grep 'word' # Find `word` in file.txt
    echo "hello world"
end

# Example 6
begin
    cat file.txt | grep 'word'
    # Find `word` in file.txt
end

# Example 7
begin
    cat file.txt | grep 'word' # Find `word` in file.txt
    # comment
end
Phidica commented 4 years ago

Thank you for the detailed report! This has helped in isolating the cause, and I'm looking into a fix now. It could take some time though, as I think you've hit upon a real sticking point and shown me a pretty important scenario that just can't be covered by the sort of compromise implementation I currently have in my syntax logic. This is a good thing! Once I fix it, the syntax shall be even stronger ;)