mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Restrict copy/paste with imports to TS 5.6+ (#215386)
Also skips when the copied file is the same as the paste file
This commit is contained in:
@@ -61,7 +61,7 @@ class DocumentPasteProvider implements vscode.DocumentPasteEditProvider {
|
||||
token: vscode.CancellationToken,
|
||||
): Promise<vscode.DocumentPasteEdit[] | undefined> {
|
||||
const config = vscode.workspace.getConfiguration(this._modeId, document.uri);
|
||||
if (!config.get('experimental.updateImportsOnPaste')) {
|
||||
if (!config.get('experimental.updateImportsOnPaste', false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,10 @@ class DocumentPasteProvider implements vscode.DocumentPasteEditProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (copiedFrom?.file === file) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await this._client.execute('getPasteEdits', {
|
||||
file,
|
||||
// TODO: only supports a single paste for now
|
||||
@@ -126,7 +130,7 @@ class DocumentPasteProvider implements vscode.DocumentPasteEditProvider {
|
||||
export function register(selector: DocumentSelector, language: LanguageDescription, client: ITypeScriptServiceClient) {
|
||||
return conditionalRegistration([
|
||||
requireSomeCapability(client, ClientCapability.Semantic),
|
||||
requireMinVersion(client, API.v550),
|
||||
requireMinVersion(client, API.v560),
|
||||
], () => {
|
||||
return vscode.languages.registerDocumentPasteEditProvider(selector.semantic, new DocumentPasteProvider(language.id, client), {
|
||||
providedPasteEditKinds: [DocumentPasteProvider.kind],
|
||||
|
||||
@@ -38,6 +38,7 @@ export class API {
|
||||
public static readonly v544 = API.fromSimpleString('5.4.4');
|
||||
public static readonly v540 = API.fromSimpleString('5.4.0');
|
||||
public static readonly v550 = API.fromSimpleString('5.5.0');
|
||||
public static readonly v560 = API.fromSimpleString('5.6.0');
|
||||
|
||||
public static fromVersionString(versionString: string): API {
|
||||
let version = semver.valid(versionString);
|
||||
|
||||
Reference in New Issue
Block a user