Skip to content
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

Pasting an array inserts a semicolon #3674

Closed
jdhines opened this issue Jan 8, 2018 · 7 comments
Closed

Pasting an array inserts a semicolon #3674

jdhines opened this issue Jan 8, 2018 · 7 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker.

Comments

@jdhines
Copy link

jdhines commented Jan 8, 2018

This doesn't reproduce in the playground, but in VS Code, if I disable every extension except Prettier, I see this issue, and if I disable Prettier, there is no semicolon insertion.

Input:

let myThings = {
  group1: [1,2,3],
  group2: [1,2],
  thing: ''
}

And if I copy [1,2,3] from the first item, select [1,2] or '' in the second or third item and paste, it inserts a semicolon after the closing bracket:
Output:

let myThings = {
  group1: [1,2,3],
  group2: [1, 2, 3];,
  thing: ''
}
//OR
let myThings = {
  group1: [1,2,3],
  group2: [1,2],
  thing: [1, 2, 3];
}

Expected behavior:
Pasting an array doesn't automatically add a semicolon at the end

@ikatyang
Copy link
Member

ikatyang commented Jan 8, 2018

It looks similar to prettier/prettier-vscode#257, and I'm not able to reproduce, can you provide your versions/settings?

kapture 2018-01-08 at 21 46 47

@ikatyang ikatyang added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Jan 8, 2018
@jdhines
Copy link
Author

jdhines commented Jan 8, 2018

It does seem similar, but I don't get that exact issue either, just when pasting an array. I'm on version 1.0.1 of prettier-vscode, which is Prettier 1.9. All prettier-vscode settings are default, but I do have "editor.formatOnPaste": true

Even if I set "prettier.semi": false it still adds the semicolon

@azz
Copy link
Member

azz commented Jan 8, 2018

/cc @CiGit @josephfrazier

@CiGit
Copy link
Member

CiGit commented Jan 8, 2018

Format on paste calls the range formatter.

$ cat test.js
let myThings = {
    group1: [1,2,3],
    group2: [1,2],
    thing: ''
}
$ npx prettier@1.5 --range-start 50 --range-end 55 test.js
let myThings = {
  group1: [1, 2, 3],
  group2: [1, 2],
  thing: ""
};
$ npx prettier@1.7 --range-start 50 --range-end 55 test.js # [1.6 - 1.7]
let myThings = {
    group1: [1,2,3],
    group2: [1, 2];,
    thing: ''
}
$ npx prettier@1.8 --range-start 50 --range-end 55 test.js # [1.8 - latest]
let myThings = {
  group1: [1, 2, 3],
  group2: [1, 2],
  thing: ""
};

I suppose you have a prettier installed locally (range 1.6 - 1.7) which is the one taken by the extension.

Over Prettier(Bottom right your editor) after having called the formatter to see which version it picked up.

@azz
Copy link
Member

azz commented Jan 8, 2018

Thanks for looking into that @CiGit.

I'll close this issue as it was probably fixed in #3069 which was in 1.8.

Re-open if this is not the case.

@azz azz closed this as completed Jan 8, 2018
@ikatyang ikatyang added type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker. and removed status:awaiting response Issues that require answers to questions from maintainers before action can be taken labels Jan 8, 2018
@jdhines
Copy link
Author

jdhines commented Jan 8, 2018

prettier@1.7.4
I see I do have that in my package.json
If I have the VS Code plugin, should I remove it from my project? Or should I just make sure the version in my project is updated?

@azz
Copy link
Member

azz commented Jan 9, 2018

Just update your local prettier to 1.9

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker.
Projects
None yet
Development

No branches or pull requests

4 participants