@@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
12
12
import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
13
13
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
14
14
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget' ;
15
- import { CTX_INLINE_CHAT_FOCUSED , CTX_INLINE_CHAT_INNER_CURSOR_FIRST , CTX_INLINE_CHAT_INNER_CURSOR_LAST , CTX_INLINE_CHAT_EMPTY , CTX_INLINE_CHAT_OUTER_CURSOR_POSITION , CTX_INLINE_CHAT_VISIBLE , MENU_INLINE_CHAT_WIDGET , MENU_INLINE_CHAT_WIDGET_STATUS , MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE , CTX_INLINE_CHAT_MESSAGE_CROP_STATE , IInlineChatSlashCommand , MENU_INLINE_CHAT_WIDGET_FEEDBACK , ACTION_REGENERATE_RESPONSE , ACTION_VIEW_IN_CHAT , MENU_INLINE_CHAT_WIDGET_TOGGLE } from 'vs/workbench/contrib/inlineChat/common/inlineChat' ;
15
+ import { CTX_INLINE_CHAT_FOCUSED , CTX_INLINE_CHAT_EMPTY , CTX_INLINE_CHAT_OUTER_CURSOR_POSITION , CTX_INLINE_CHAT_VISIBLE , MENU_INLINE_CHAT_WIDGET , MENU_INLINE_CHAT_WIDGET_STATUS , MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE , CTX_INLINE_CHAT_MESSAGE_CROP_STATE , IInlineChatSlashCommand , MENU_INLINE_CHAT_WIDGET_FEEDBACK , ACTION_REGENERATE_RESPONSE , ACTION_VIEW_IN_CHAT , MENU_INLINE_CHAT_WIDGET_TOGGLE , CTX_INLINE_CHAT_INNER_CURSOR_FIRST , CTX_INLINE_CHAT_INNER_CURSOR_LAST } from 'vs/workbench/contrib/inlineChat/common/inlineChat' ;
16
16
import { IModelDeltaDecoration , ITextModel } from 'vs/editor/common/model' ;
17
17
import { EventType , Dimension , addDisposableListener , getActiveElement , getTotalHeight , getTotalWidth , h , reset } from 'vs/base/browser/dom' ;
18
18
import { Emitter , Event , MicrotaskEmitter } from 'vs/base/common/event' ;
@@ -234,9 +234,24 @@ export class InlineChatWidget {
234
234
235
235
// (1) inner cursor position (last/first line selected)
236
236
const updateInnerCursorFirstLast = ( ) => {
237
- const { lineNumber } = this . _inputEditor . getPosition ( ) ;
238
- this . _ctxInnerCursorFirst . set ( lineNumber === 1 ) ;
239
- this . _ctxInnerCursorLast . set ( lineNumber === this . _inputModel . getLineCount ( ) ) ;
237
+ const selection = this . _inputEditor . getSelection ( ) ;
238
+ let onFirst = false ;
239
+ let onLast = false ;
240
+ if ( selection . isEmpty ( ) ) {
241
+ const selectionTop = this . _inputEditor . getTopForPosition ( selection . startLineNumber , selection . startColumn ) ;
242
+ const fullRange = this . _inputModel . getFullModelRange ( ) ;
243
+ const firstViewLineTop = this . _inputEditor . getTopForPosition ( fullRange . startLineNumber , fullRange . startColumn ) ;
244
+ const lastViewLineTop = this . _inputEditor . getTopForPosition ( fullRange . endLineNumber , fullRange . endColumn ) ;
245
+
246
+ if ( selectionTop === firstViewLineTop ) {
247
+ onFirst = true ;
248
+ }
249
+ if ( selectionTop === lastViewLineTop ) {
250
+ onLast = true ;
251
+ }
252
+ }
253
+ this . _ctxInnerCursorFirst . set ( onFirst ) ;
254
+ this . _ctxInnerCursorLast . set ( onLast ) ;
240
255
} ;
241
256
this . _store . add ( this . _inputEditor . onDidChangeCursorPosition ( updateInnerCursorFirstLast ) ) ;
242
257
updateInnerCursorFirstLast ( ) ;
0 commit comments