Skip to content

Commit 38b2b7c

Browse files
committed
initial swapping implementation
only between patches
1 parent a159d2d commit 38b2b7c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

coderibbon-theia/src/browser/cr-ribbon.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,36 @@ export class CodeRibbonTheiaRibbonPanel
346346
// this.addWidget(widget, { mode: 'split-bottom' });
347347
// break;
348348
case "widget-all":
349+
crdebug("patch swap because widget-all drop zone");
349350
// TODO swap if from another patch & self not empty
350351
// this.addWidget(widget, { mode: 'tab-after', ref });
351352
// this.addWidget(widget, { mode: 'split-down', ref });
352353
if (target_patch) {
353354
if (target_patch.contentful_size == 0) {
355+
crdebug("target_patch is empty, nothing to swap");
356+
target_patch.addWidget(widget);
357+
} else {
358+
crdebug("Swapping widgets between patches.");
359+
let other_widget = target_patch.contentful_widget;
360+
if (!other_widget) {
361+
console.error(
362+
"CR: attempted to swap patch content but target patch is missing a widget when it was contenful.",
363+
);
364+
break;
365+
}
366+
if (!source_patch) {
367+
crdebug(
368+
"patch received a drop from somewhere that wasn't a patch, but we're full right now!",
369+
);
370+
// TODO what is the desired behavior here?
371+
// perhaps split-down or split-right?
372+
break;
373+
}
374+
source_patch.addWidget(other_widget);
354375
target_patch.addWidget(widget);
355-
} else if (source_patch) {
356-
// TODO swap their contents
357376
}
377+
} else {
378+
crdebug("no target_patch for the drop? where are we going?");
358379
}
359380
break;
360381
case "widget-top":

0 commit comments

Comments
 (0)