@@ -577,22 +577,37 @@ setWindowInputAndEvaluate // endDefinition;
577
577
attachToLeft // beginDefinition ;
578
578
579
579
attachToLeft [ source_ NotebookObject , current_ NotebookObject ] := Enclose [
580
- Module [ { mag , width , margins , left , bottom , top },
580
+ Module [ { mag , width , margins , left , bottom , top , displayindex , displayleftedge },
581
581
582
582
mag = Replace [ AbsoluteCurrentValue [ source , Magnification ], Except [ _ ? NumberQ ] :> 1.0 ];
583
583
width = Ceiling @ ConfirmBy [ $workspaceChatWidth * mag , NumberQ , "Width" ];
584
584
margins = ConfirmMatch [ windowMargins @ source , { { _ , _ }, { _ , _ } }, "Margins" ];
585
+
586
+ displayindex = NotebookTools ` NotebookDisplayIndex [source ];
587
+ displayleftedge = If [IntegerQ [displayindex ],
588
+ Replace [CurrentValue ["ConnectedDisplays" ][[displayindex ]], {
589
+ {___ , "FullRegion" -> {{xmin_ , _ }, {_ , _ }}, ___ } :> xmin ,
590
+ _ :> 0
591
+ }],
592
+ 0
593
+ ];
585
594
586
595
left = margins [[ 1 , 1 ]];
587
596
bottom = margins [[ 2 , 1 ]];
588
597
top = margins [[ 2 , 2 ]];
589
598
590
- If [ NonPositive [ left - width ], left = width ];
599
+ left = left - width ;
600
+ If [ left < displayleftedge ,
601
+ (* prevent the assistant from falling off the left edge of the display *)
602
+ left = displayleftedge ;
603
+ (* Uncomment this to also slide the source notebook right, to avoid overlapping with the assistant *)
604
+ (* SetOptions[source, WindowMargins -> ReplacePart[margins, {1,1} -> (left + width)]] *)
605
+ ];
591
606
592
607
SetOptions [
593
608
current ,
594
609
Magnification -> 0.85 * mag ,
595
- WindowMargins -> { { left - width , Automatic }, { bottom , top } },
610
+ WindowMargins -> { { left , Automatic }, { bottom , top } },
596
611
WindowSize -> { width , Automatic }
597
612
];
598
613
0 commit comments