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

Fixing slow paste with spinner #61032

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

navya9singh
Copy link
Member

This pr fixes #60485 by making preparePasteEdits return false if an import statement is selected. This is a fix for now that will stop the spinner, but I will be working on #59841 that would enable pasteEdits to fix import specifiers and will also take care of this delay.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jan 23, 2025
Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Do JavaScript requires and export { foo } from "./bar" need to be considered?

@@ -25,6 +32,12 @@ export function preparePasteEdits(
ancestorNode => rangeContainsRange(ancestorNode, range),
);
if (!enclosingNode) return;
if (
Copy link
Member

Choose a reason for hiding this comment

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

Do all these conditions work if only a an identifier is selected? What about part of the module specifier? The test only shows the case where an entire import declaration is selected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, if only an identifier is selected, it works too because it doesn't enter this if block, instead tries to enter the forEachChild but since it doesn't have any children it just returns and moves to the next iteration. Same for moduleSpecifier. If this is selected { foo }, then it will enter the if block.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add tests to show that it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

slow paste with spinner
3 participants