Skip to content

Inconsistent single quote expansion inside of double quotes #6

@TrevorBurnham

Description

@TrevorBurnham

Inside of single quotes, double quote expansion works as you'd expect: A pair is always formed; if you select text, then double quotes are formed around it.

Now try typing

"#{foo}"

If you place the cursor at the end of the string and type ', you get one single quote:

"#{foo}'"

If you place the cursor at the start of the string and do the same, you get two:

"''#{foo}"

And if you select anything inside of the string (outside of the interpolation), the ' you type simply replaces what you've selected:

"'"

But within the interpolation, single quote expansions work as you'd expect:

"#{'foo'}"

The behaviors are identical with backticks (`) as well.

None of these behaviors is so bad in and of itself, but the inconsistency is annoying. I'm guessing that it's the result of someone overthinking a bit—what's the behavior supposed to be if a selection includes part of an interpolation when someone hits '? But that's an edge case (the selection was probably made by mistake); a much more common case is when you want to surround an interpolation with single quotes:

"You typed '#{input}'."

Right now, doing that common operation takes not one keystroke, not two, but at least three—one to put a pair of single quotes in front of the interpolation, another to delete half the pair, and another to add a single quote after it.

I think it would be a great improvement to simply expand all single quotes (and backticks) typed inside of double quotes, the way that double quotes are always expanded inside of single quotes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions