mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-06 13:39:23 +01:00
Enable copy paste api in scm input (#209466)
* Enable dnd and copy paste apis in scm input For #209460 Enables dropping or pasting a file from the vscode/system explorer into the scminput to insert the file name. Currently nothing happens when you try this In the future will also allow extensions to hook into these apis * Revert organize imports * Remove duplication
This commit is contained in:
@@ -164,6 +164,9 @@ export class PostEditWidgetManager<T extends DocumentPasteEdit | DocumentOnDropE
|
||||
}
|
||||
|
||||
const resolvedEdit = await resolve(edit, token);
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
|
||||
const combinedWorkspaceEdit = createCombinedWorkspaceEdit(model.uri, ranges, resolvedEdit);
|
||||
|
||||
@@ -174,6 +177,7 @@ export class PostEditWidgetManager<T extends DocumentPasteEdit | DocumentOnDropE
|
||||
options: { description: 'paste-line-suffix', stickiness: TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges }
|
||||
}]);
|
||||
|
||||
this._editor.focus();
|
||||
let editResult: IBulkEditResult;
|
||||
let editRange: Range | null;
|
||||
try {
|
||||
@@ -183,6 +187,10 @@ export class PostEditWidgetManager<T extends DocumentPasteEdit | DocumentOnDropE
|
||||
model.deltaDecorations(editTrackingDecoration, []);
|
||||
}
|
||||
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (canShowWidget && editResult.isApplied && edits.allEdits.length > 1) {
|
||||
this.show(editRange ?? primaryRange, edits, async (newEditIndex) => {
|
||||
const model = this._editor.getModel();
|
||||
|
||||
@@ -331,7 +331,7 @@ registerEditorCommand(new CommandCtor({
|
||||
handler: ctrl => ctrl.next(),
|
||||
kbOpts: {
|
||||
weight: KeybindingWeight.EditorContrib + 30,
|
||||
kbExpr: EditorContextKeys.editorTextFocus,
|
||||
kbExpr: EditorContextKeys.textInputFocus,
|
||||
primary: KeyCode.Tab
|
||||
}
|
||||
}));
|
||||
@@ -341,7 +341,7 @@ registerEditorCommand(new CommandCtor({
|
||||
handler: ctrl => ctrl.prev(),
|
||||
kbOpts: {
|
||||
weight: KeybindingWeight.EditorContrib + 30,
|
||||
kbExpr: EditorContextKeys.editorTextFocus,
|
||||
kbExpr: EditorContextKeys.textInputFocus,
|
||||
primary: KeyMod.Shift | KeyCode.Tab
|
||||
}
|
||||
}));
|
||||
@@ -351,7 +351,7 @@ registerEditorCommand(new CommandCtor({
|
||||
handler: ctrl => ctrl.cancel(true),
|
||||
kbOpts: {
|
||||
weight: KeybindingWeight.EditorContrib + 30,
|
||||
kbExpr: EditorContextKeys.editorTextFocus,
|
||||
kbExpr: EditorContextKeys.textInputFocus,
|
||||
primary: KeyCode.Escape,
|
||||
secondary: [KeyMod.Shift | KeyCode.Escape]
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import { Button, ButtonWithDescription, ButtonWithDropdown } from 'vs/base/brows
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { RepositoryContextKeys } from 'vs/workbench/contrib/scm/browser/scmViewService';
|
||||
import { DragAndDropController } from 'vs/editor/contrib/dnd/browser/dnd';
|
||||
import { CopyPasteController } from 'vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
|
||||
import { DropIntoEditorController } from 'vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController';
|
||||
import { MessageController } from 'vs/editor/contrib/message/browser/messageController';
|
||||
import { defaultButtonStyles, defaultCountBadgeStyles } from 'vs/platform/theme/browser/defaultStyles';
|
||||
@@ -2491,6 +2492,7 @@ class SCMInputWidget {
|
||||
ColorDetector.ID,
|
||||
ContextMenuController.ID,
|
||||
DragAndDropController.ID,
|
||||
CopyPasteController.ID,
|
||||
DropIntoEditorController.ID,
|
||||
LinkDetector.ID,
|
||||
MenuPreventer.ID,
|
||||
@@ -2502,7 +2504,7 @@ class SCMInputWidget {
|
||||
InlineCompletionsController.ID,
|
||||
CodeActionController.ID,
|
||||
FormatOnType.ID,
|
||||
EditorDictation.ID
|
||||
EditorDictation.ID,
|
||||
])
|
||||
};
|
||||
|
||||
@@ -2529,6 +2531,11 @@ class SCMInputWidget {
|
||||
}, 0);
|
||||
}));
|
||||
|
||||
this.disposables.add(this.inputEditor.onDidBlurEditorWidget(() => {
|
||||
CopyPasteController.get(this.inputEditor)?.clearWidgets();
|
||||
DropIntoEditorController.get(this.inputEditor)?.clearWidgets();
|
||||
}));
|
||||
|
||||
const firstLineKey = this.contextKeyService.createKey<boolean>('scmInputIsInFirstPosition', false);
|
||||
const lastLineKey = this.contextKeyService.createKey<boolean>('scmInputIsInLastPosition', false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user