Skip to content

Commit c706653

Browse files
committed
resolve comment
1 parent 5cf19b8 commit c706653

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/SourceViewerComposite.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void focusGained(FocusEvent e) {
128128

129129
@Override
130130
public void focusLost(FocusEvent e) {
131-
hideActionButtons(null);
131+
hideActionButtons();
132132
}
133133
});
134134

@@ -144,7 +144,7 @@ public void mouseEnter(MouseEvent e) {
144144

145145
@Override
146146
public void mouseExit(MouseEvent e) {
147-
hideActionButtons(new Point(e.x, e.y));
147+
hideActionButtons();
148148
}
149149
});
150150

@@ -229,23 +229,27 @@ private void showActionButtons() {
229229
actionsComposite.setVisible(true);
230230
}
231231

232-
private void hideActionButtons(Point cursorLocation) {
232+
private void hideActionButtons() {
233233
if (this.actionsComposite == null || this.actionsComposite.isDisposed()) {
234234
return;
235235
}
236236
SwtUtils.invokeOnDisplayThreadAsync(() -> {
237237
if (actionsComposite == null || actionsComposite.isDisposed()) {
238238
return;
239239
}
240-
if (!isCursorWithinCodeBlockActions(cursorLocation) && !isFocusWithinCodeBlockActions()) {
240+
if (!isCursorWithinCodeBlockActions() && !isFocusWithinCodeBlockActions()) {
241241
actionsComposite.moveBelow(sourceViewer.getTextWidget());
242242
actionsComposite.setVisible(false);
243243
}
244244
}, this);
245245
}
246246

247-
private boolean isCursorWithinCodeBlockActions(Point cursorLocation) {
248-
return cursorLocation != null && actionsComposite.getBounds().contains(cursorLocation);
247+
private boolean isCursorWithinCodeBlockActions() {
248+
Point cursorLocation = actionsComposite.getDisplay().getCursorLocation();
249+
Point actionsLocation = actionsComposite.toDisplay(0, 0);
250+
Point actionsSize = actionsComposite.getSize();
251+
Rectangle actionsBounds = new Rectangle(actionsLocation.x, actionsLocation.y, actionsSize.x, actionsSize.y);
252+
return actionsBounds.contains(cursorLocation);
249253
}
250254

251255
private boolean isFocusWithinCodeBlockActions() {

0 commit comments

Comments
 (0)