-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Adding preparePasteEdits method to check if smart copy/paste should be applied #60053
Conversation
Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary. |
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up. |
src/services/services.ts
Outdated
@@ -2300,6 +2303,16 @@ export function createLanguageService( | |||
}; | |||
} | |||
|
|||
function preparePasteEditsForFile(fileName: string, copiedTextRange: TextRange[]): boolean { | |||
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); | |||
bindSourceFile(sourceFile, getDefaultCompilerOptions()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not suppose to bind the file on syntax server. Also the options used here are wrong as they should be host.getCompilationSettings()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the binding, I don't get any locals
or symbol.exports
in the sourceFile. Is there a different way of doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If thats the case you would need this command on "partial semantic" or "semantic server" instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protocol changes look good. Thanks for looking into this! Will adopt it on the VS Code side once merged
This pr adds a
preparePasteEdits
api to check ifpasteEdits
should be performed. #59881One drawback here is, a case where the copied text is
export const a = 1;
, this would return true, because it checks if an identifier is exported in the current source file. This is needed, so that a case likewhere
const b = a
is the copied text, can be true.