Skip to content

Commit

Permalink
Enable dnd and copy paste apis in scm input
Browse files Browse the repository at this point in the history
For microsoft#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
  • Loading branch information
mjbvz committed Apr 3, 2024
1 parent fd5ac01 commit b89ad44
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 {
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/contrib/snippet/browser/snippetController2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}));
Expand All @@ -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
}
}));
Expand All @@ -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]
}
Expand Down
Loading

0 comments on commit b89ad44

Please sign in to comment.