@@ -12,6 +12,7 @@ import { SimpleWorkerClient, logOnceWebWorkerWarning } from 'vs/base/common/work
12
12
import { DefaultWorkerFactory } from 'vs/base/worker/defaultWorkerFactory' ;
13
13
import * as editorCommon from 'vs/editor/common/editorCommon' ;
14
14
import * as modes from 'vs/editor/common/modes' ;
15
+ import { Position } from 'vs/editor/common/core/position' ;
15
16
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService' ;
16
17
import { IModelService } from 'vs/editor/common/services/modelService' ;
17
18
import { EditorSimpleWorkerImpl } from 'vs/editor/common/services/editorSimpleWorker' ;
@@ -46,14 +47,7 @@ export class EditorWorkerServiceImpl implements IEditorWorkerService {
46
47
return wireCancellationToken ( token , this . _workerManager . withWorker ( ) . then ( client => client . computeLinks ( model . uri ) ) ) ;
47
48
}
48
49
} ) ;
49
- const completionProvider = modes . SuggestRegistry . register ( '*' , < modes . ISuggestSupport > {
50
- provideCompletionItems : ( model , position , token ) => {
51
- if ( configurationService . lookup < boolean > ( 'editor.wordBasedSuggestions' ) . value ) {
52
- return this . _workerManager . withWorker ( ) . then ( client => client . textualSuggest ( model . uri , position ) ) ;
53
- }
54
- return undefined ;
55
- }
56
- } ) ;
50
+ const completionProvider = modes . SuggestRegistry . register ( '*' , new WordBasedCompletionItemProvider ( this . _workerManager , configurationService ) ) ;
57
51
this . _registrations = [ linkProvider , completionProvider ] ;
58
52
}
59
53
@@ -81,7 +75,24 @@ export class EditorWorkerServiceImpl implements IEditorWorkerService {
81
75
public navigateValueSet ( resource : URI , range : editorCommon . IRange , up : boolean ) : TPromise < modes . IInplaceReplaceSupportResult > {
82
76
return this . _workerManager . withWorker ( ) . then ( client => client . navigateValueSet ( resource , range , up ) ) ;
83
77
}
78
+ }
79
+
80
+ class WordBasedCompletionItemProvider implements modes . ISuggestSupport {
84
81
82
+ private readonly _workerManager : WorkerManager ;
83
+ private readonly _configurationService : IConfigurationService ;
84
+
85
+ constructor ( workerManager : WorkerManager , configurationService : IConfigurationService ) {
86
+ this . _workerManager = workerManager ;
87
+ this . _configurationService = configurationService ;
88
+ }
89
+
90
+ provideCompletionItems ( model : editorCommon . IModel , position : Position ) : TPromise < modes . ISuggestResult > {
91
+ if ( ! this . _configurationService . lookup < boolean > ( 'editor.wordBasedSuggestions' ) . value ) {
92
+ return undefined ;
93
+ }
94
+ return this . _workerManager . withWorker ( ) . then ( client => client . textualSuggest ( model . uri , position ) ) ;
95
+ }
85
96
}
86
97
87
98
class WorkerManager extends Disposable {
0 commit comments