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.92k stars 302 forks source link

Autocomplete with Debug.Print before variable #5005

Open SonGokussj4 opened 5 years ago

SonGokussj4 commented 5 years ago

Description With MsgBox, it behaves like #4900 With Debug.Print it's different

To Reproduce

  1. Debug.Print |this.dc.TableName
  2. Type "

Expected behavior Debug.Print "|this.dc.TableName

Resulting behavior Debug.Print "|"; this.dc.TableName

daFreeMan commented 5 years ago

I'm not the expert, but I believe that is status-by-design - it's closed the " pair for you. It doesn't know that you want to make this.dc.TableName part of the string literal that you're creating by enclosing it in quotes.

My take on your Expected behavior is that you want SCP to be disabled if the line starts with Debug.Print.

Vogel612 commented 5 years ago

I'm retagging this as enhancement because the resulting behaviour is the current designed status. The suggestion to change the autocompletion behaviour could have some merit, but I wouldn't classify this as a bug...

retailcoder commented 5 years ago

@daFreeMan is correct; SCP is doing its job and auto-closes "" the double-quotes for you, not knowing the intent is to later go to the end of the expression and " close the string.

Debug.Print "" something

The above would be illegal; the semicolon is inserted by the VBE to make the expression legal:

Debug.Print ""; something

There's a //todo comment somewhere in the SCP code, to make it "wrap" the selection, so you would have this:

Debug.Print [something here]

Where [something here] is the selection; hitting " would "wrap" the something here content with double quotes, resulting in:

Debug.Print "something here"|

Other than that, I'm not very keen on disabling SCP handling based on arbitrary criterion (e.g. disable when left-of-caret content says Debug.Print) - that seems a good way to spaghettify the feature and make it work in unexpected ways.

SonGokussj4 commented 5 years ago

Okay. I understand you all. The //todo would definitely resolve this thing. Will wait for the future. :-) Is there any way to, as @daFreeMan mentioned, disable SCP for debug.print line? Or to disable "some types of autocomplete"? If I'm not mistaken (maybe I am :-)), in the past, there were more options in Autocomplete Settings.