Skip to content

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

Open
@pokey

Description

@pokey

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions