Skip to content

Commit 50056f3

Browse files
authored
Finalize drop into editor api (microsoft#155102)
Fixes microsoft#142990 Fixes microsoft#149779
1 parent bec36ce commit 50056f3

File tree

8 files changed

+59
-73
lines changed

8 files changed

+59
-73
lines changed

extensions/markdown-language-features/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"configuration.markdown.links.openLocation.currentGroup": "Open links in the active editor group.",
2929
"configuration.markdown.links.openLocation.beside": "Open links beside the active editor.",
3030
"configuration.markdown.suggest.paths.enabled.description": "Enable/disable path suggestions for markdown links",
31-
"configuration.markdown.editor.drop.enabled": "Enable/disable dropping into the markdown editor to insert shift. Requires enabling `#workbench.experimental.editor.dropIntoEditor.enabled#`.",
31+
"configuration.markdown.editor.drop.enabled": "Enable/disable dropping into the markdown editor to insert shift. Requires enabling `#workbench.editor.dropIntoEditor.enabled#`.",
3232
"configuration.markdown.editor.pasteLinks.enabled": "Enable/disable pasting files into a Markdown editor inserts Markdown links. Requires enabling `#editor.experimental.pasteActions.enabled#`.",
3333
"configuration.markdown.experimental.validate.enabled.description": "Enable/disable all error reporting in Markdown files.",
3434
"configuration.markdown.experimental.validate.referenceLinks.enabled.description": "Validate reference links in Markdown files, e.g. `[link][ref]`. Requires enabling `#markdown.experimental.validate.enabled#`.",

src/vs/editor/contrib/dropIntoEditor/browser/dropIntoEditorContribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class DropIntoEditorController extends Disposable implements IEditorContr
4646
this._languageFeaturesService.documentOnDropEditProvider.register('*', new DefaultOnDropProvider(workspaceContextService));
4747

4848
this._register(this._configurationService.onDidChangeConfiguration(e => {
49-
if (e.affectsConfiguration('workbench.experimental.editor.dropIntoEditor.enabled')) {
49+
if (e.affectsConfiguration('workbench.editor.dropIntoEditor.enabled')) {
5050
this.updateEditorOptions(editor);
5151
}
5252
}));
@@ -56,7 +56,7 @@ export class DropIntoEditorController extends Disposable implements IEditorContr
5656

5757
private updateEditorOptions(editor: ICodeEditor) {
5858
editor.updateOptions({
59-
enableDropIntoEditor: this._configurationService.getValue('workbench.experimental.editor.dropIntoEditor.enabled')
59+
enableDropIntoEditor: this._configurationService.getValue('workbench.editor.dropIntoEditor.enabled')
6060
});
6161
}
6262

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
577577
return extHostLanguages.createLanguageStatusItem(extension, id, selector);
578578
},
579579
registerDocumentDropEditProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentDropEditProvider): vscode.Disposable {
580-
checkProposedApiEnabled(extension, 'textEditorDrop');
581580
return extHostLanguageFeatures.registerDocumentOnDropEditProvider(extension, selector, provider);
582581
}
583582
};

src/vs/workbench/browser/parts/editor/editorDropTarget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface IDropOperation {
3232
}
3333

3434
function isDropIntoEditorEnabledGlobally(configurationService: IConfigurationService) {
35-
return configurationService.getValue<boolean>('workbench.experimental.editor.dropIntoEditor.enabled');
35+
return configurationService.getValue<boolean>('workbench.editor.dropIntoEditor.enabled');
3636
}
3737

3838
function isDragIntoEditorEvent(e: DragEvent): boolean {

src/vs/workbench/browser/workbench.contribution.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
466466
'default': 'both',
467467
'description': localize('layoutControlType', "Controls whether the layout control in the custom title bar is displayed as a single menu button or with multiple UI toggles."),
468468
},
469+
'workbench.editor.dropIntoEditor.enabled': {
470+
'type': 'boolean',
471+
'default': true,
472+
'markdownDescription': localize('dropIntoEditor', "Controls whether you can drag and drop a file into a text editor by holding down `shift` (instead of opening the file in an editor)."),
473+
},
469474
'workbench.experimental.layoutControl.enabled': {
470475
'type': 'boolean',
471476
'tags': ['experimental'],
@@ -486,12 +491,6 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
486491
'description': localize('layoutControlType', "Controls whether the layout control in the custom title bar is displayed as a single menu button or with multiple UI toggles."),
487492
'markdownDeprecationMessage': localize({ key: 'layoutControlTypeDeprecation', comment: ['{0} is a placeholder for a setting identifier.'] }, "This setting has been deprecated in favor of {0}", '`#workbench.layoutControl.type#`')
488493
},
489-
'workbench.experimental.editor.dropIntoEditor.enabled': {
490-
'type': 'boolean',
491-
'default': true,
492-
'tags': ['experimental'],
493-
'markdownDescription': localize('dropIntoEditor', "Controls whether you can drag and drop a file into a text editor by holding down `shift` (instead of opening the file in an editor)."),
494-
}
495494
}
496495
});
497496

src/vs/workbench/services/extensions/common/extensionsApiProposals.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const allApiProposals = Object.freeze({
5959
terminalExitReason: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalExitReason.d.ts',
6060
testCoverage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testCoverage.d.ts',
6161
testObserver: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts',
62-
textEditorDrop: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textEditorDrop.d.ts',
6362
textSearchProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts',
6463
timeline: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.timeline.d.ts',
6564
tokenInformation: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tokenInformation.d.ts',

src/vscode-dts/vscode.d.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5407,6 +5407,46 @@ declare module 'vscode' {
54075407
provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
54085408
}
54095409

5410+
/**
5411+
* An edit operation applied {@link DocumentDropEditProvider on drop}.
5412+
*/
5413+
export class DocumentDropEdit {
5414+
/**
5415+
* The text or snippet to insert at the drop location.
5416+
*/
5417+
insertText: string | SnippetString;
5418+
5419+
/**
5420+
* An optional additional edit to apply on drop.
5421+
*/
5422+
additionalEdit?: WorkspaceEdit;
5423+
5424+
/**
5425+
* @param insertText The text or snippet to insert at the drop location.
5426+
*/
5427+
constructor(insertText: string | SnippetString);
5428+
}
5429+
5430+
/**
5431+
* Provider which handles dropping of resources into a text editor.
5432+
*
5433+
* The user can drop into a text editor by holding down `shift` while dragging. Requires `workbench.editor.dropIntoEditor.enabled` to be on.
5434+
*/
5435+
export interface DocumentDropEditProvider {
5436+
/**
5437+
* Provide edits which inserts the content being dragged and dropped into the document.
5438+
*
5439+
* @param document The document in which the drop occurred.
5440+
* @param position The position in the document where the drop occurred.
5441+
* @param dataTransfer A {@link DataTransfer} object that holds data about what is being dragged and dropped.
5442+
* @param token A cancellation token.
5443+
*
5444+
* @return A {@link DocumentDropEdit} or a thenable that resolves to such. The lack of a result can be
5445+
* signaled by returning `undefined` or `null`.
5446+
*/
5447+
provideDocumentDropEdits(document: TextDocument, position: Position, dataTransfer: DataTransfer, token: CancellationToken): ProviderResult<DocumentDropEdit>;
5448+
}
5449+
54105450
/**
54115451
* A tuple of two characters, like a pair of
54125452
* opening and closing brackets.
@@ -12785,6 +12825,16 @@ declare module 'vscode' {
1278512825
*/
1278612826
export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable;
1278712827

12828+
/**
12829+
* Registers a new {@link DocumentDropEditProvider}.
12830+
*
12831+
* @param selector A selector that defines the documents this provider applies to.
12832+
* @param provider A drop provider.
12833+
*
12834+
* @return A {@link Disposable} that unregisters this provider when disposed of.
12835+
*/
12836+
export function registerDocumentDropEditProvider(selector: DocumentSelector, provider: DocumentDropEditProvider): Disposable;
12837+
1278812838
/**
1278912839
* Set a {@link LanguageConfiguration language configuration} for a language.
1279012840
*

src/vscode-dts/vscode.proposed.textEditorDrop.d.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)