Rubberduck: 3739-pre : Autocompletion disabled, still seems to affect the typing (Adding unwanted double quotes and parenthesis)

Created on 31 Aug 2018  路  7Comments  路  Source: rubberduck-vba/Rubberduck

While editing any type of text, pressing the key " to close a string produces 2 quotes instead of one.

For example, pressing the keys : " Y " should result in "Y", but it actually results in "Y"", even with autocomplete disabled. The issue disappears with RD uninstalled.

I have not found any reference of this specific bug yet but I might be wrong

bug critical feature-autocomplete

Most helpful comment

There is no way to disable the VBE's 'autocorrect' because the result is exactly what the VBE thinks you entered on the first place.

Let me give a bit background regarding this. The VBE comes from a time where space was not abundant. So, whenever you enter a line of code, it gets compiled to an intermediate format, pcode, like IL for .Net or bytecode for Java. This gets saved and the actual gets thrown away. What you see in the code pane is basically a decompilation of the pcode. That is why the VBE 'pretty-prints' your code and you cannot do anything about it.

All 7 comments

I will also add that again, with Autocompletion fully disabled, adding an open parenthesis automatically adds the closing parenthesis. It's like Autocompletion is still active

Another example, if I have the following code
Obj.Item() and I try to put a " in the parenthesis, it results in Obj.Item()" instead of Obj.Item(")

Just for reference: Which version are you using? From a quick test with 3739-pre it seems to me that the autocomplete settings are

  • either not correctly representing their actual state
  • or not working at all.

(Meaning, I can reproduce the issue you described.)

It is 3739, yes

Confirmed repro here.

I had this:

  <AutoCompleteSettings IsEnabled="false" CompleteBlockOnTab="true" CompleteBlockOnEnter="true" EnableSmartConcat="true">

Then changed it to this:

  <AutoCompleteSettings IsEnabled="false" CompleteBlockOnTab="false" CompleteBlockOnEnter="false" EnableSmartConcat="false">

And AC still somehow manages to wire up, and ignores its "master switch" IsEnabled setting. @FuSoftware by editing the .config file to set EnableSmartConcat to false, the bug/feature is no longer enabled though.

As for obj.Item(), the reason AC is struggling with obj.Item() is because you're missing a space between Item and the opening (, that the VBE automatically inserts when RD's self-closing pairs (despite being disabled, but that's another issue) add the closing ).

So if you have this (where | represents the caret position):

msgbox|

And type a (, RD attempts to get to this:

msgbox(|)

However the VBE desperately wants to do this:

MsgBox (|)

So if that whitespace isn't present, when you type the " here:

msgbox("|)

The VBE does this:

MsgBox ("|)

And then RD overwrites it to this:

msgbox("|")

Except at that point it's fighting a lost battle against the VBE, and RD loses track of what's where, because it now finds a " where there was a ( a split-second earlier - and " being the closing character of the "" pair, drops the closing character because it's already there.

Everything falls into place if you drop the redundant parentheses, or type the whitespace the VBE slips in:

 msgbox ("|)

correctly results in

MsgBox ("|")

And

msgbox "|

correctly results in

MsgBox "|"

The hard part is not accounting for that whitespace. The hard part is accounting for the actual behavior of the VBE, which will take this:

msgbox                                                   ("wut")

And turn it into this:

MsgBox ("wut")

Clearly autocompletion in the VBE is much harder than I originally thought. I'll probably altogether un-ship the feature for the v2.3.0 "green release", and re-include it (with a properly-working killswitch) in 2.3.x pre-release builds.

Thanks for the insight on why stuff happens. I am no VBE COM expert, but isn't there a way to disable VBE's own autocorrect at this point, so you can fully build yours without accounting for any possible undesirable behaviour from it ?

There is no way to disable the VBE's 'autocorrect' because the result is exactly what the VBE thinks you entered on the first place.

Let me give a bit background regarding this. The VBE comes from a time where space was not abundant. So, whenever you enter a line of code, it gets compiled to an intermediate format, pcode, like IL for .Net or bytecode for Java. This gets saved and the actual gets thrown away. What you see in the code pane is basically a decompilation of the pcode. That is why the VBE 'pretty-prints' your code and you cannot do anything about it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

retailcoder picture retailcoder  路  4Comments

ThunderFrame picture ThunderFrame  路  3Comments

Gener4tor picture Gener4tor  路  3Comments

retailcoder picture retailcoder  路  3Comments

retailcoder picture retailcoder  路  3Comments