atom / toggle-quotes

An Atom package to toggle between single and double quotes
MIT License
77 stars 36 forks source link

Toggling doesn't work with strings in an array in YAML file #63

Open mobilesfinks opened 6 years ago

mobilesfinks commented 6 years ago

Description

It does not switch quotes in yaml files, but at the same time it work in the newly created file with the JS extension.

Disable yaml linter and extensions - not helped

Example from yaml file (some.yaml) (Not Work)

    volumes: 
      etcdbackup: 
        pvc: etcdbackup
        size: 50Gi
        accessModes: ["ReadWriteOnce"]

Example from JS file (test.js) (Worked)

function test () { return "hello"; }
    size: 50Gi
    accessModes: ['ReadWriteOnce']

Versions

Atom : 1.25.1 Electron: 1.7.11 Chrome : 58.0.3029.110 Node : 7.9.0

apm 1.19.0 npm 3.10.10 node 6.9.5 x64 atom 1.25.1 python 2.7.12 git 2.7.4

toggle-quotes 1.1.1

rsese commented 6 years ago

Thanks for the report - it looks like strings in arrays is the issue in your example? If accessModes is just a string rather than a string in an array, it looks like toggling quotes works in that case.

I can reproduce with 1.31.0-nightly11 on macOS 10.12.6.

mobilesfinks commented 6 years ago

Yes exactly. I checked it locally. That's how it works. If just string - all work fine Work

        accessModes: "ReadWriteOnce"

not work

args: ["-c",  "/root/bin/ceph_db_update.sh dev dev"]
Aerijo commented 6 years ago

It looks like the entire array is scoped as an unquoted string; it's not actually scoped as an array at all. I don't know why this is, but it precludes toggle-quotes from working. That package is generic for many / all languages, so requires the string scope to identify the range of the string.