rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

TODO Explorer picking up a "done" in the text of a comment when it shouldn't #5124

Open SmileyFtW opened 5 years ago

SmileyFtW commented 5 years ago

Rubberduck version information Version 2.4.1.4901 OS: Microsoft Windows NT 10.0.18362.0, x64 Host Product: Microsoft Office x86 Host Version: 16.0.11901.20218 Host Executable: EXCEL.EXE

Description In the "Done" group a line of comment using the word "done" shows up when it is not really a "Done" annotation (or whatever it should be called.

To Reproduce Steps to reproduce the behavior:

  1. add a "Done" to the todo settings
  2. create a comment containing the word done: "module contains info on what was done..."
  3. open the Todo Explorer
  4. See that line

Expected behavior Only a "Done" as the first word in a comment line should show up in the TE

Screenshots If applicable, add screenshots to help explain your problem. image Logfile RubberduckLog.txt

SmileyFtW commented 5 years ago

If any text (e.g. "todo") is found anywhere in a comment line that will be picked up by the TE? I didn't think that was the way it was intended to work; I thought it was only supposed to pick up the string as the first characters in a comment line. My apologies for reporting this as a bug if anywhere in a comment line is the desired behavior.

retailcoder commented 5 years ago

@SmileyFtW no, my apologies for not actually replying with a comment! I meant to put up a screenshot of how R# matches markers in VS and explain that indeed it was intended to work that way - but if it feels wrong, then it should probably be more flexible. Would exposing a regex pattern make todo markers too complicated to configure? I don't think the majority of VBIDE users are comfortable with regex...

zspitz commented 5 years ago

A consideration against exposing a regex pattern -- aren't there differences between .NET regex syntax and the VBScript regex syntax used in VBA? Would it be possible/better to leverage the VBScript regex engine for this?

Perhaps allowing only a Like pattern?

bclothier commented 5 years ago

TBH, I never liked the R# behavior of matching the marker anywhere in the text. 99.9999% of time, I want the marker following the comment marker and maybe whitespace, no more. KISS.

Vogel612 commented 5 years ago

@zspitz the primary consideration against exposing a regex pattern would IMO be the potential for the user to accidentally completely deadlock the parsing/recognition process. The VBScript flavored regexes are baaically a strict subset of the .NET regexes.

Overall, I'd vote for the simplification proposed by @bclothier. This means we'd wrap the todo marker into $"^\\s*{pattern}\\b" so we only match the todo marker as a single word at the beginning of a comment. (The pattern still needs to be escaped here)

I just don't see much of a usecase for pattern based todo markers...

SmileyFtW commented 5 years ago

I wouldn't know what to do with a regex pattern, and it seems like a big can of nasty worms to open. That being said, I am with blothier in that I expect to use the TE tags as the first thing after the opening single-quote (or multiple ones) and possibly with some whitespace ahead of the tag... nothing more. I had simply thought that was the design and the way it worked until I put that "done" in a comment and discovered otherwise. My other tags (todo, nextup) are not likely to ever pop up like "done" did as part of a real comment.