iqsharp icon indicating copy to clipboard operation
iqsharp copied to clipboard

Incorrect syntax highlighting for non-word character immediately preceding a keyword

Open tcNickolas opened this issue 6 years ago • 1 comments

Describe the bug Syntax highlighting in IQ# exhibits several issues:

  • Type names at the end of operation names are highlighted as types
  • Characters before reserved words are highlighted as part of those words
  • Reserved words at the beginning of the line (without whitespace before them) are not highlighted

To Reproduce Add the following Q# code to a Q# notebook:

operation SyntaxHighlight () : Unit {

// Type names at the end of operation names are highlighted
ControlledOnInt();
AssertQubit();
ApplyPauliFromBitString(PauliX, true, negate, inputs);

// Characters before reserved words are highlighted as part of those words
{let b =Length(array);}
ApplyToEach(X, array);
ApplyPauliFromBitString(PauliX,true, negate, inputs);
let array = [false, false];

// Reserved words at the beginning of the line (without whitespace before them) are not highlighted
let a = Length();
Adjoint Z(qubit);
Message("Hi");
}

Screenshots

image

System information

  • OS: Windows 10
  • Browser: Firefox

Additional context image

tcNickolas avatar Jan 03 '20 02:01 tcNickolas

Since #151 has now been merged, the current behavior for the sample code in the original issue description now looks like this:

image

Updating title to reflect the remaining issue here, which is that a single non-word character immediately preceding a keyword still gets highlighted as part of the keyword. This is existing behavior, and I haven't found a way to fix this within the confines of CodeMirror simple mode. We would have to implement a custom mode, which would give us a lot more flexibility but would also be a much larger task.

rmshaffer avatar Jun 03 '20 20:06 rmshaffer