Skip to content

Commit

Permalink
revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Jan 9, 2025
1 parent 0b83d22 commit f0b0b2d
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ export class ChatWidget extends Disposable implements IChatWidget {

readonly viewContext: IChatWidgetViewContext;

private _activeElement: HTMLElement | undefined;

constructor(
location: ChatAgentLocation | IChatWidgetLocationOptions,
_viewContext: IChatWidgetViewContext | undefined,
Expand Down Expand Up @@ -455,36 +453,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
}).filter(isDefined);

this._register((this.chatWidgetService as ChatWidgetService).register(this));

this._setupFocusObserver();
}

private _setupFocusObserver(): void {
this.listContainer.addEventListener('focus', () => {
const element = dom.getActiveElement() as HTMLElement | null;
if (this._activeElement !== element && element !== null) {
this._activeElement = element;
this._scrollToActiveElement(this._activeElement);
}
}, true);
}


private _scrollToActiveElement(element: HTMLElement) {
const containerRect = this.listContainer.getBoundingClientRect();
const elementRect = element.getBoundingClientRect();

const topOffset = elementRect.top - containerRect.top;
// TODO: figure out why 20 is needed here, remove if possible
const bottomOffset = elementRect.bottom - containerRect.bottom + this.listContainer.clientHeight - 20;

if (topOffset < 0) {
// Scroll up
this.tree.scrollTop += topOffset;
} else if (bottomOffset > 0) {
// Scroll down
this.tree.scrollTop += bottomOffset;
}
}

private scrollToEnd() {
Expand Down

0 comments on commit f0b0b2d

Please sign in to comment.