3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
+ import type { Terminal as RawXtermTerminal } from '@xterm/xterm' ;
6
7
import { Dimension , IFocusTracker , trackFocus } from 'vs/base/browser/dom' ;
7
8
import { Event } from 'vs/base/common/event' ;
8
9
import { Disposable , toDisposable } from 'vs/base/common/lifecycle' ;
@@ -14,7 +15,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
14
15
import { ChatAgentLocation } from 'vs/workbench/contrib/chat/common/chatAgents' ;
15
16
import { IChatProgress } from 'vs/workbench/contrib/chat/common/chatService' ;
16
17
import { InlineChatWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget' ;
17
- import { ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal' ;
18
+ import { ITerminalInstance , type IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal' ;
18
19
import { MENU_TERMINAL_CHAT_INPUT , MENU_TERMINAL_CHAT_WIDGET , MENU_TERMINAL_CHAT_WIDGET_FEEDBACK , MENU_TERMINAL_CHAT_WIDGET_STATUS , TerminalChatCommandId , TerminalChatContextKeys } from 'vs/workbench/contrib/terminalContrib/chat/browser/terminalChat' ;
19
20
import { TerminalStickyScrollContribution } from 'vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollContribution' ;
20
21
@@ -37,6 +38,7 @@ export class TerminalChatWidget extends Disposable {
37
38
constructor (
38
39
private readonly _terminalElement : HTMLElement ,
39
40
private readonly _instance : ITerminalInstance ,
41
+ private readonly _xterm : IXtermTerminal & { raw : RawXtermTerminal } ,
40
42
@IInstantiationService private readonly _instantiationService : IInstantiationService ,
41
43
@IContextKeyService private readonly _contextKeyService : IContextKeyService
42
44
) {
@@ -75,7 +77,7 @@ export class TerminalChatWidget extends Disposable {
75
77
this . _register ( Event . any (
76
78
this . _inlineChatWidget . onDidChangeHeight ,
77
79
this . _instance . onDimensionsChanged ,
78
- Event . debounce ( this . _instance . xterm ! . raw . onCursorMove , ( ) => void 0 , MicrotaskDelay ) ,
80
+ Event . debounce ( this . _xterm . raw . onCursorMove , ( ) => void 0 , MicrotaskDelay ) ,
79
81
) ( ( ) => this . _relayout ( ) ) ) ;
80
82
81
83
const observer = new ResizeObserver ( ( ) => this . _relayout ( ) ) ;
@@ -138,7 +140,7 @@ export class TerminalChatWidget extends Disposable {
138
140
return ;
139
141
}
140
142
if ( top > terminalWrapperHeight - widgetHeight ) {
141
- this . _setTerminalOffset ( widgetHeight ) ;
143
+ this . _setTerminalOffset ( top - ( terminalWrapperHeight - widgetHeight ) ) ;
142
144
} else {
143
145
this . _setTerminalOffset ( undefined ) ;
144
146
}
@@ -171,7 +173,6 @@ export class TerminalChatWidget extends Disposable {
171
173
this . _terminalElement . style . position = 'relative' ;
172
174
this . _terminalElement . style . bottom = `${ offset } px` ;
173
175
TerminalStickyScrollContribution . get ( this . _instance ) ?. hideLock ( ) ;
174
-
175
176
}
176
177
}
177
178
focus ( ) : void {
0 commit comments