Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Handle escaped characters when autocompleting quotes - #276

Merged
winstliu merged 2 commits into
masterfrom
wl-andyfriesen-escape-quotes
Feb 24, 2017
Merged

winstliu merged 2 commits into
masterfrom
wl-andyfriesen-escape-quotes

Conversation

@winstliu

Copy link
Copy Markdown
Contributor

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

This PR builds on #201. Changes include:

  • Rewriting the backslash-checking logic. This was flat-out wrong to begin with, and could only check the two previous characters.
    • Now scans the entire line for a continuous string of backslashes that terminate at the end of the line.
    • If the number of backslashes is odd, then there is an escape character and the quote will not be skipped.
  • Adding a regex to check for escape sequences.
    • Similar to escape characters, except that the number of backslashes is even or there are an odd number of backslashes, followed by any character, followed by the end of the line.
    • If there is an escape sequence, quotes will not be paired.

Consequences of these changes:

  • "|", where | is the position of the cursor
    • Typing a backslash followed by a quote results in the same behavior as before: it inserts a new quote, rather than completing the quote pair
    • Typing two backslashes followed by a quote: quote pair is completed
    • Typing three backslashes followed by a quote: new quote is inserted, rather than completing the quote pair
  • "|, where | is the position of the cursor
    • Typing any number of backslashes followed by a quote results in the same behavior as before: it inserts a single new quote

Alternate Designs

None.

Benefits

Finally being able to type double-backslashes without having to backspace, delete, and otherwise be annoyed

Possible Drawbacks

Should be none. I was unable to spot any regressions, and there's comprehensive test coverage.

Applicable Issues

Fixes #80
Supersedes and closes #201

andyfriesen and others added 2 commits February 23, 2017 10:16
And make sure that insertNewline/backspace use the new logic as well
@winstliu

Copy link
Copy Markdown
Contributor Author

/cc @andyfriesen

@lee-dohm

Copy link
Copy Markdown
Contributor

Looks good to me 👍 Definitely an improvement.

@winstliu
winstliu merged commit 39df386 into master Feb 24, 2017
@winstliu
winstliu deleted the wl-andyfriesen-escape-quotes branch February 24, 2017 04:52
@winstliu

Copy link
Copy Markdown
Contributor Author

Thanks @andyfriesen for getting this started.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backslash prevents pair autocompletion

3 participants