@@ -16,7 +16,7 @@ import { Range } from '../../../../editor/common/core/range.js';
16
16
import { IPosition , Position } from '../../../../editor/common/core/position.js' ;
17
17
import { AbstractInlineChatAction } from './inlineChatActions.js' ;
18
18
import { EditorContextKeys } from '../../../../editor/common/editorContextKeys.js' ;
19
- import { InjectedTextCursorStops , IValidEditOperation , TrackedRangeStickiness } from '../../../../editor/common/model.js' ;
19
+ import { IValidEditOperation , TrackedRangeStickiness } from '../../../../editor/common/model.js' ;
20
20
import { URI } from '../../../../base/common/uri.js' ;
21
21
import { isEqual } from '../../../../base/common/resources.js' ;
22
22
import { StandardTokenType } from '../../../../editor/common/encodedTokenAttributes.js' ;
@@ -36,6 +36,8 @@ import { IConfigurationService } from '../../../../platform/configuration/common
36
36
import { Event } from '../../../../base/common/event.js' ;
37
37
import { observableCodeEditor } from '../../../../editor/browser/observableCodeEditor.js' ;
38
38
import { PLAINTEXT_LANGUAGE_ID } from '../../../../editor/common/languages/modesRegistry.js' ;
39
+ import { createStyleSheet2 } from '../../../../base/browser/domStylesheets.js' ;
40
+ import { stringValue } from '../../../../base/browser/cssValue.js' ;
39
41
40
42
export const CTX_INLINE_CHAT_SHOWING_HINT = new RawContextKey < boolean > ( 'inlineChatShowingHint' , false , localize ( 'inlineChatShowingHint' , "Whether inline chat shows a contextual hint" ) ) ;
41
43
@@ -149,12 +151,6 @@ export class ShowInlineChatHintAction extends EditorAction2 {
149
151
}
150
152
}
151
153
152
- class HintData {
153
- constructor (
154
- readonly setting : string
155
- ) { }
156
- }
157
-
158
154
export class InlineChatHintsController extends Disposable implements IEditorContribution {
159
155
160
156
public static readonly ID = 'editor.contrib.inlineChatHints' ;
@@ -193,16 +189,18 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
193
189
if ( e . target . type !== MouseTargetType . CONTENT_TEXT ) {
194
190
return ;
195
191
}
196
- const attachedData = e . target . detail . injectedText ?. options . attachedData ;
197
- if ( ! ( attachedData instanceof HintData ) ) {
192
+ if ( ! e . target . element ?. classList . contains ( 'inline-chat-hint-text' ) ) {
198
193
return ;
199
194
}
200
195
if ( e . event . leftButton ) {
201
196
commandService . executeCommand ( _inlineChatActionId ) ;
202
197
this . hide ( ) ;
203
198
} else if ( e . event . rightButton ) {
204
199
e . event . preventDefault ( ) ;
205
- this . _showContextMenu ( e . event , attachedData . setting ) ;
200
+ this . _showContextMenu ( e . event , e . target . element ?. classList . contains ( 'whitespace' )
201
+ ? InlineChatConfigKeys . LineEmptyHint
202
+ : InlineChatConfigKeys . LineNLHint
203
+ ) ;
206
204
}
207
205
} ) ) ;
208
206
@@ -251,6 +249,9 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
251
249
return undefined ;
252
250
} ) ;
253
251
252
+ const style = createStyleSheet2 ( ) ;
253
+ this . _store . add ( style ) ;
254
+
254
255
this . _store . add ( autorun ( r => {
255
256
256
257
const showData = showDataObs . read ( r ) ;
@@ -264,7 +265,7 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
264
265
const agentName = chatAgentService . getDefaultAgent ( ChatAgentLocation . Editor ) ?. name ?? localize ( 'defaultTitle' , "Chat" ) ;
265
266
const { position, isEol, isWhitespace, kb, model } = showData ;
266
267
267
- const inlineClassName : string [ ] = [ 'inline-chat-hint' ] ;
268
+ const inlineClassName : string [ ] = [ 'a' /*HACK but sorts as we want*/ , ' inline-chat-hint' , 'inline-chat-hint-text '] ;
268
269
let content : string ;
269
270
if ( isWhitespace ) {
270
271
content = '\u00a0' + localize ( 'title2' , "{0} to edit with {1}" , kb , agentName ) ;
@@ -275,6 +276,11 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
275
276
inlineClassName . push ( 'embedded' ) ;
276
277
}
277
278
279
+ style . setStyle ( `.inline-chat-hint-text::after { content: ${ stringValue ( content ) } }` ) ;
280
+ if ( isWhitespace ) {
281
+ inlineClassName . push ( 'whitespace' ) ;
282
+ }
283
+
278
284
this . _ctxShowingHint . set ( true ) ;
279
285
280
286
decos . set ( [ {
@@ -283,13 +289,7 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
283
289
description : 'inline-chat-hint-line' ,
284
290
showIfCollapsed : true ,
285
291
stickiness : TrackedRangeStickiness . NeverGrowsWhenTypingAtEdges ,
286
- after : {
287
- content,
288
- inlineClassName : inlineClassName . join ( ' ' ) ,
289
- inlineClassNameAffectsLetterSpacing : true ,
290
- cursorStops : InjectedTextCursorStops . None ,
291
- attachedData : new HintData ( isWhitespace ? InlineChatConfigKeys . LineEmptyHint : InlineChatConfigKeys . LineNLHint )
292
- }
292
+ afterContentClassName : inlineClassName . join ( ' ' ) ,
293
293
}
294
294
} ] ) ;
295
295
0 commit comments