notepad-plus-plus / notepad-plus-plus

Notepad++ official repository
https://notepad-plus-plus.org/
Other
23.09k stars 4.62k forks source link

Bug in Ruby Syntax Highlighting for symbols #9918

Open rovf opened 3 years ago

rovf commented 3 years ago

Description of the Issue

Steps to Reproduce the Issue

I have the following Ruby function definition:

def foo(s=%s.'".)
   p s
end

It defines a function foo, which accepts one optional argument s. If the caller does not specify a parameter, a default value is used. The default value is of Ruby type Symbol, and it is a symbol consiting of two characters: A single quote an a double quote. Hence, if this function would be invoked by

 foo

Ruby would print

:"'\""

which is how Ruby formats this type of symbols when printing using p.

Expected Behavior

I would expect that the Ruby syntax highlighter shows %s.'". in the colour of a symbol, and the following closing parenthese in the colour it uses for parentheses.

Actual Behavior

The syntax highlighter gets out of step when seeing the single quote, and seems to believe that this is the start of a string. It colours the remaining code as if it were a string.

Debug Information

Notepad++ v7.7.1 (64-bit) Build time : Jun 16 2019 - 21:24:47 Path : C:\p\nppp64bit\notepad++.exe Admin mode : OFF Local Conf mode : ON OS : Windows 10 (64-bit) Plugins : AnalysePlugin.dll AutoEolFormat.dll Comment Wrap.dll ComparePlugin.dll CustomLineNumbers.dll MenuIcons.dll mimeTools.dll NppConverter.dll NppFavorites.dll NppXmlTreeviewPlugin.dll SelectQuotedText.dll SurroundSelection.dll XBrackets.dll _CustomizeToolbar.dll capture_20210528_102330

ArkadiuszMichalski commented 3 years ago

Not duplicate of https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4964?

rovf commented 3 years ago

No. That issue was that %s Symbol sequences are not recognized. In fact, most are coloured well, but that one isn't. My gut feeling is that the colorizer gets out of step if the symbol contains a single quote.

ArkadiuszMichalski commented 3 years ago

You should report this for Lexilla (for LexRuby.cxx lexer). From my editors, it seems only Sublime Text does it right: image This is correct behavior?

rovf commented 3 years ago

The image you posted looks great.

Why should I post it to "Lexilla"? I don't use Lexilla directly, so if I post it there, they may say that the developers of NP++ made some mistake in integrating it. Wouldn't it make more sense, if someone from the NP++ developers, who has insight into how Lexilla has been integrated, forwards this case to Lexilla? For instance, I couldn't even tell them which version of the Lexilla library is used here.

ArkadiuszMichalski commented 3 years ago

Notepad ++ use the Scintilla component (Lexilla is part of it), so if you want correct behaviour you should report this issue there. If this is fixed in Lexilla, then Notepad++ will also work properly (when update this module to next version).

sasumner commented 3 years ago

@rovf Notepad++ developers don't have time to track down lexing bugs in Scintilla. Sad but true, maybe. What you can do, if you want to put the effort in, is to try your specific case in the current version of Scintilla's demo text editor, SciTE. If it works the same way there, you could feel good about putting an issue into Scintilla's bug tracker about it. If it doesn't then it probably warrants more discussion here.

zufuliu commented 1 year ago

This is due to the percent literal %s.'". is not recognized, filled https://github.com/ScintillaOrg/lexilla/issues/124.