-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Describe the bug
In a non-js/ts file, when pasting a piece of text, the text is pasted, and a semicolon as well as linebreak are inserted after the pasted text.
This issue does not occur in TS/JS files. I've seen it only in other files (e.g. .md, .yml, etc)
To Reproduce
Inside a README.md

After pasting

You can see the ;\n was not part of the clipboard, it is nevertheless added.
Interestingly, the issue doesnt occur when the pasted content has spaces in it:


In such case we get a console error
Error: Unexpected keyword or identifier. (1:1)
> 1 | text to paste
| ^
SyntaxError: Unexpected keyword or identifier. (1:1)
> 1 | text to paste
| ^
at D (/home/me/project/node_modules/prettier/parser-typescript.js:1:17162)
at LT (/home/me/project/node_modules/prettier/parser-typescript.js:257:10765)
at Object.RT [as parse] (/home/me/project/node_modules/prettier/parser-typescript.js:257:11074)
at Object.parse (/home/me/project/node_modules/prettier/index.js:7515:23)
at coreFormat (/home/me/project/node_modules/prettier/index.js:8829:18)
at formatWithCursor2 (/home/me/project/node_modules/prettier/index.js:9021:18)
at /home/me/project/node_modules/prettier/index.js:38169:12
at Object.format (/home/me/project/node_modules/prettier/index.js:38183:12)
at /home/me/.vscode/extensions/rvest.vs-code-prettier-eslint-5.0.4/dist/extension.js:184:131
at Lge (/home/me/.vscode/extensions/rvest.vs-code-prettier-eslint-5.0.4/dist/extension.js:180:1160)
So it seems like even if the file is NOT a JS/TS, the extension tries to parse the content of the clipboard and do some magic with it. The space in the content makes this unwanted behavior crash.
Versions (please complete the following information):
- VS Code Prettier ESLint extension 5.0.4
- Visual Studio Code: 1.74.2
- Node: 16.17.1
- Package Manager yarn 1.22.19
- prettier: 2.8.2
- eslint: 8.31.0
System Specifications (please complete the following information):
- OS: Ubuntu