Skip to content

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 requested a review from sheetalkamat May 21, 2024 17:17
@navya9singh navya9singh merged commit 11b73ec into microsoft:main May 21, 2024
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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