Skip to content

Commit 618b587

Browse files
committed
check model version id before/after going to the extension host
1 parent bd71718 commit 618b587

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/vs/workbench/api/browser/mainThreadEditors.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,16 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
163163
}
164164

165165
private async onDropIntoEditor(editor: ICodeEditor, position: IPosition, dragEvent: DragEvent) {
166-
if (!dragEvent.dataTransfer) {
166+
if (!dragEvent.dataTransfer || !editor.hasModel()) {
167167
return;
168168
}
169169
const id = this._editorLocator.getIdOfCodeEditor(editor);
170170
if (typeof id !== 'string') {
171171
return;
172172
}
173173

174+
const modelVersionNow = editor.getModel().getVersionId();
175+
174176
const textEditorDataTransfer: IDataTransfer = new Map<string, IDataTransferItem>();
175177
for (const item of dragEvent.dataTransfer.items) {
176178
if (item.kind === 'string') {
@@ -207,8 +209,10 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
207209
return;
208210
}
209211

210-
const [first] = edits; // TODO define how to pick the "one snippet edit";
211-
performSnippetEdit(editor, first);
212+
if (editor.getModel().getVersionId() === modelVersionNow) {
213+
const [first] = edits; // TODO@jrieken define how to pick the "one snippet edit";
214+
performSnippetEdit(editor, first);
215+
}
212216
}
213217

214218
// --- from extension host process

0 commit comments

Comments
 (0)