[Qt-creator] It's time to fix double redundant quotes

Jason H jhihn at gmx.com
Wed Mar 9 18:27:08 CET 2016


It seems we are unanimous on the don't-remove-both-quotes-on-backspace.

I am open to sme auto-quoting behavior, so let's explore this. As Eike starts to do:

> > Would break case a) from above for e.g. function arguments:
> > 
> > 	foo(|)
> > 	foo(|,1)

someFunc(" - ok to insert " and move cursor 1 space back: = someFunc("|"
this is sometext" - NOT ok to insert " and move cursor 1 space back: = sometext"|" <- this won't ever happen in source, unless it's some kind of text decorator
What I meant to do above is start with a ", however I missed it, and the auto insert behavior just makes it worse. It might be cool if it was really intelligent and figured out that due to EOL or whitespace to the right that it was the end quote and go find the best place for the open quote:
this is sometext" - BOL = "this is sometext"|
someFunc(this is sometext" - back up to (, advance to first non-whitespace, insert " = someFunc("this is sometext"|
someFunc2(a, this is someText" - back up to ,, advance to first non-whitespace, insert " = someFunc(a, "this is sometext"|


However that logic would fail with:
// someFunc(QString longstring)
someFunc( No. As I said, the other" -> someFunc( No, As I said, "the other" (which isn't a terrible guess. but without some rich AST, we can't do better) 
At which point, I'd argue that we're hurting as much as helping. (50%/50% on if we are right)
If there is an AST, we can work backwards from the EOL " grabbing tokens that aren't symbols defined in the code, until we arrive at:
someFunc( "No. As I said, the other" 

Absent the AST logic, I'd say do nothing.





More information about the Qt-creator mailing list