Skip to content

Conversation

@idahogurl
Copy link
Owner

@idahogurl idahogurl commented Apr 22, 2023

Closes #139

What

  • Format on Paste uses the registered DocumentRangeFormattingEditProvider for formatting. Instead of providing the range for the entire document, it provides the range for the pasted text. This causes semi-colons and commas to be inserted because pretter-eslint only supports formatting the entire document.

How

Create range using document line count instead of using provided range

Comment on lines +30 to +33
const startLine = document.lineAt(0);
const endLine = document.lineAt(document.lineCount - 1);
const range = new Range(startLine.range.start, endLine.range.end);

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create range for entire document not just for the selected text.

Comment on lines -45 to +50
provideDocumentRangeFormattingEdits(document, range) {
return formatter(document, range);
provideDocumentRangeFormattingEdits(document) {
return formatter(document);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore provided range

@idahogurl idahogurl added the minor Increment the minor version when merged label Apr 22, 2023
@idahogurl idahogurl merged commit fea20ac into master Apr 22, 2023
@idahogurl idahogurl deleted the 139-extension-inserts-unwanted-semicolon-and branch December 1, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension inserts unwanted semicolon and linebreak upon pasting into a non ts/js file

1 participant