Skip to content

Leverage same mechanism used by surrounding pairs in token whitespace removal logic #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pokey opened this issue Jul 6, 2023 · 0 comments

Comments

@pokey
Copy link
Member

pokey commented Jul 6, 2023

The problem

As of #1564, we determine whether we should remove whitespace in part based on whether the remaining adjacent token is an opening / closing pair. This mostly works, but has a couple problems:

  • We duplicate our source of truth about which tokens are considered opening / closing pairs
  • The logic breaks down in complex cases, eg when it's not obvious whether a " is opening or closing (see test case below)

The solution

We should find a way to leverage the code we use in surrounding pairs to determine if a token is opening or closing

Dependencies

Test cases to add

The following test case fails today, but should pass:

languageId: plaintext
command:
  version: 5
  spokenForm: chuck token
  action: {name: remove}
  targets:
    - type: primitive
      modifiers:
        - type: containingScope
          scopeType: {type: token}
  usePrePhraseSnapshot: true
initialState:
  documentContents: "\"aaa\".length + 1"
  selections:
    - anchor: {line: 0, character: 5}
      active: {line: 0, character: 12}
  marks: {}
finalState:
  documentContents: "\"aaa\" + 1"
  selections:
    - anchor: {line: 0, character: 5}
      active: {line: 0, character: 5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant