@@ -12,6 +12,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
1212import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
1313import { SuggestController } from 'vs/editor/contrib/suggest/suggestController' ;
1414import { ITextModel } from 'vs/editor/common/model' ;
15+ import { Range } from 'vs/editor/common/core/range' ;
1516import { Position } from 'vs/editor/common/core/position' ;
1617import { registerEditorAction , ServicesAccessor , EditorAction } from 'vs/editor/browser/editorExtensions' ;
1718import { IModelService } from 'vs/editor/common/services/modelService' ;
@@ -37,7 +38,7 @@ import { IDecorationOptions } from 'vs/editor/common/editorCommon';
3738import { transparent , editorForeground } from 'vs/platform/theme/common/colorRegistry' ;
3839import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
3940import { FocusSessionActionViewItem } from 'vs/workbench/contrib/debug/browser/debugActionViewItems' ;
40- import { CompletionContext , CompletionList , CompletionProviderRegistry } from 'vs/editor/common/modes' ;
41+ import { CompletionContext , CompletionList , CompletionProviderRegistry , CompletionItem , completionKindFromString , CompletionItemKind } from 'vs/editor/common/modes' ;
4142import { first } from 'vs/base/common/arrays' ;
4243import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
4344import { ITreeNode , ITreeContextMenuEvent , IAsyncDataSource } from 'vs/base/browser/ui/tree/tree' ;
@@ -141,7 +142,34 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
141142 const text = model . getValue ( ) ;
142143 const focusedStackFrame = this . debugService . getViewModel ( ) . focusedStackFrame ;
143144 const frameId = focusedStackFrame ? focusedStackFrame . frameId : undefined ;
144- const suggestions = await session . completions ( frameId , text , position , overwriteBefore , token ) ;
145+ const response = await session . completions ( frameId , text , position , overwriteBefore , token ) ;
146+
147+ const suggestions : CompletionItem [ ] = [ ] ;
148+ const computeRange = ( length : number ) => Range . fromPositions ( position . delta ( 0 , - length ) , position ) ;
149+ if ( response && response . body && response . body . targets ) {
150+ response . body . targets . forEach ( item => {
151+ if ( item && item . label ) {
152+ suggestions . push ( {
153+ label : item . label ,
154+ insertText : item . text || item . label ,
155+ kind : completionKindFromString ( item . type || 'property' ) ,
156+ filterText : ( item . start && item . length ) ? text . substr ( item . start , item . length ) . concat ( item . label ) : undefined ,
157+ range : computeRange ( item . length || overwriteBefore ) ,
158+ sortText : item . sortText
159+ } ) ;
160+ }
161+ } ) ;
162+ }
163+
164+ const history = this . history . getHistory ( ) ;
165+ history . forEach ( h => suggestions . push ( {
166+ label : h ,
167+ insertText : h ,
168+ kind : CompletionItemKind . Text ,
169+ range : computeRange ( h . length ) ,
170+ sortText : 'ZZZ'
171+ } ) ) ;
172+
145173 return { suggestions } ;
146174 }
147175
0 commit comments