ionide / ionide-fsgrammar

Shared Textmate Regex Style F# Language Grammar
MIT License
35 stars 36 forks source link

Infix multiplication operator is treated as block comment terminator #207

Closed mbottini closed 9 months ago

mbottini commented 9 months ago

Describe the bug Inside of a block comment, the infix multiplication operator (*) is treated as the terminator of a block comment. This is not correct; F# tokenizes keywords inside of comments, and since (*) is a keyword, it and the *) inside it is discarded.

To Reproduce Steps to reproduce the behaviour:

  1. Open a new F# file.
  2. Type the following expression:

    (* This is a comment that include (*) This should also be a comment! *)

Expected behaviour The syntax highlighter should associate the closing paren of the infix operator with its opening paren and not be associated with the paren that came before it.

Screenshot

image

Environment (please complete the following information):

mbottini commented 9 months ago

(Sorry, completely new to this)

It looks like this should be two separate bugs, since the rules are handled in completely different parts of the grammar. The comment block bug is, I think, due to the regex that the grammar uses to detect endCapture here: https://github.com/ionide/ionide-fsgrammar/blob/master/grammars/fsharp.json#L559C40-L559C40

(\\*+\\))

This should match iff

  1. The expression is at the beginning of the line, in which case there's no way for it to be an opening paren.
  2. If not, the character that precedes this is not an opening parenthesis.

I need to figure out a development environment for iterating on my machine to confirm - regexes are finicky and easy to get wrong.

baronfel commented 9 months ago

@mbottini thanks for reporting and considering contributing! There are instructions to debug the changes in CONTRIBUTING.md - it should just be F5'ing in the repo. There's a dummy extension that loads your changes.

mbottini commented 9 months ago

This part should be resolved by the pull request. I'm going to split off the other issue (the infix multiplication operator itself) into another issue.