vscode-cfml icon indicating copy to clipboard operation
vscode-cfml copied to clipboard

Auto terminate quotation after period adds extra quote

Open redtopia opened this issue 6 years ago • 11 comments

When ending the quotation of a string that ends with a period, an extra quotation character is added as if a new string is being created. See below:

screenshot

redtopia avatar Jun 11 '19 05:06 redtopia

This is automatically handled by VS Code when providing " as an auto-closing pair. This could probably be avoided by indicating that this character should not be auto-closed in a string, but for CFML it's useful to do this since that is how quotes are escaped. Is there a reason that you are deleting the quote?

KamasamaK avatar Jun 11 '19 20:06 KamasamaK

Deleting a quote seems to happen at various times throughout the day for various reasons. But it happens often enough where I find it problematic.

redtopia avatar Jun 11 '19 20:06 redtopia

Can I tweak this behavior outside of the CFML extension?

redtopia avatar Jun 11 '19 21:06 redtopia

You can try adding the following to your settings "editor.autoClosingQuotes": "never"

KamasamaK avatar Jun 11 '19 21:06 KamasamaK

Thanks... I’ll give that a try, but I do like when they auto-close. What I don’t like is when they auto-close when they shouldn’t. Is there anything in your extension that modifies the auto-close behavior?

redtopia avatar Jun 11 '19 21:06 redtopia

In my settings, Auto Closing Quotes is set to languageDefined. Are there any behaviors that can be modified via the CFML extension? I really don't want to turn it off globally because I do like the feature, and it seems like the behavior I've identified in this issue could be improved.

redtopia avatar Jun 11 '19 22:06 redtopia

I linked the part that defines the auto-closing behavior above. From there, VS Code handles it.

EDIT: To accomplish what I mentioned above, you would need to change line 15 to { "open": "\"", "close": "\"", "notIn": ["string"] } in your local file. Although be aware that this will be overwritten whenever there's an extension update.

KamasamaK avatar Jun 11 '19 23:06 KamasamaK

I made the change you recommended and it works correctly now.

FYI, this was broken in one of the first versions of the Sublime Text 3 extension (https://github.com/jcberquist/sublimetext-cfml), and was fixed. See last screenshot for how it currently works in ST3. As far as allowing a double quote to be auto-completed within a string, I don't believe it would be everyone's preference to preserve that behavior at the expense of this issue. I took a 3 day class with Ortus where I watched the instructor struggle with auto-closing quotes due to this exact issue. At the very least, if you want to preserve the current functionality, perhaps there is a way to make this a user setting?

Prior to change: screenshot

After change: screenshot2

This is how the Sublime Text 3 CFML plugin works: screenshot3

redtopia avatar Jun 12 '19 20:06 redtopia

For the record, this is what I changed in language-configuration.json:

"autoClosingPairs": [
    ["{", "}"],
    ["[", "]"],
    ["(", ")"],
    { "open": "\"", "close": "\"", "notIn": ["string"] },
    { "open": "'", "close": "'", "notIn": ["string"] },
    ["#", "#"]
],

Also, I noticed that there is another setting, autoCloseBefore, which is not being used. You could probably use it to further tweak/improve upon the current behavior.

See: https://code.visualstudio.com/api/language-extensions/language-configuration-guide

redtopia avatar Jun 12 '19 20:06 redtopia

I do not believe this is able to be a dynamic or user setting for language configuration. There may be an open issue for VS Code about this, but I could not find it. I can see why this may be an annoyance, but I wouldn't call it "broken" or "incorrect". I'm just not sure how it's a common occurrence that the closing quote is removed.

It's certainly possible to implement a custom auto-closing functionality, but I'm just not sure it would be worth doing so and would ideally need a proper parser (as with most missing or buggy features).

KamasamaK avatar Jun 12 '19 20:06 KamasamaK

Thank you for responding... changing it as you recommended has definitely made my life better! :)

redtopia avatar Jun 12 '19 20:06 redtopia