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 a case when text is pasted into a blank file #58595

Merged
merged 3 commits into from
May 21, 2024

Conversation

navya9singh
Copy link
Member

The copy/paste api was tested on the vscode side and a bug was found when pasting to a blank text file. It was caused by checkingDebug.assert() on a blank text file. This is fixed by adding Debug.checkDefined() instead.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 20, 2024
Comment on lines 2241 to 2244
const originalText = Debug.checkDefined(this.program?.getSourceFile(rootFile)?.getText());
Debug.assert(this.program && this.program.getSourceFile(rootFile));

this.getScriptInfo(rootFile)?.editContent(0, this.program.getSourceFile(rootFile)!.getText().length, updatedText);
Copy link
Member

@sheetalkamat sheetalkamat May 20, 2024

Choose a reason for hiding this comment

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

Suggested change
const originalText = Debug.checkDefined(this.program?.getSourceFile(rootFile)?.getText());
Debug.assert(this.program && this.program.getSourceFile(rootFile));
this.getScriptInfo(rootFile)?.editContent(0, this.program.getSourceFile(rootFile)!.getText().length, updatedText);
const originalText = Debug.checkDefined(Debug.checkDefined(this.program?.getSourceFile(rootFile), "Expected file to be part of program").getText(), "Expected some text in the file");
this.getScriptInfo(rootFile)?.editContent(0, originalText.length, updatedText)

@navya9singh navya9singh merged commit 11b73ec into microsoft:main May 21, 2024
28 checks passed
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants