Open bclothier opened 4 years ago
Something is off with the condition / expected behavior - if the number of double quotes on either side of the caret isn't odd*, then the caret isn't in the middle of a string literal.
The first quote was inserted without AC intervention because the caret is in the middle of a string literal; seems what you really want/expect, is for AC to stop bailing out inside a string literal.
If AC doesn't bail out, then the first "
keypress would have resulted with "|"
and the manual concatenation would have been seamless. Right?
* yeah it's actually more complicated than that ;-)
If you mean from this:
foo = "abc| def"
"
keypress to:
foo = "abc"|" def"
that might work.... provided that the VBIDE doesn't try to get cute and insert a ;
or something silly.
I think what is requested here is that AC does not kick in if the line ends in a non-terminated string literal.
Linking #5340
Argh that's correct, VBE steps in unless we push the feature into mind-reading territory and complete with " & | & "
... wait what if it actually did that, and did ""|
when the Ctrl key is being held down?
Otherwise yeah, bailing out is the only possible solution.
The default should probably be no-op / bail out.
Perhaps configurable Ctrl/Shift + "
combos can then be added to explicitly (as in "I asked for this to happen")...
&
concat the parts: "abc|xyz"
-> "abc" &| "xyz"
.
By placing the caret after the &
operator, we help avoid the operator accidentally parsing (by both RD & VB) as a type hint. It also makes it seamless to then just start typing some variable's identifier name. Backspacing in this state could possibly revert to the single-string literal state, so backspace/"
could round-trip!"abc |xyz"
-> "abc ""|xyz"
, with the caret placed after so we can resume typing the quoted content. Backspacing could easily clear two consecutive double-quotes, with care to account for and avoid deleting the first of them.Starting to think backspace handling should also be no-op /bail out (i.e. let the VBE handle it business as usual) by default, and optionally enabled with configurable control/shift/none keys as well.
Rubberduck version information Version 2.5.0.5524 OS: Microsoft Windows NT 10.0.14393.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.12527.20880 Host Executable: MSACCESS.EXE
Description Auto completion doesn't seem to work sanely when in a middle of string. This becomes quite annoying when constructing long strings that needs variable interpolated.
To Reproduce Given the code:
I want to modify this and insert a variable, so I type
" & bar &
, leaving me at this:I then type
"
and the autocomplete kicks in:This is now invalid line and I have to delete the
"
, add a space between the&
and the remaining"
to get me this valid line:Expected behavior I think the simplest fix is to prevent autocompletion when interpolating in middle of a string, especially if the line contains odd number of quoting characters.