@@ -148,80 +148,81 @@ export const runServer = (
148
148
) {
149
149
return undefined ;
150
150
}
151
- const complitionList =
151
+ const completionList =
152
152
await languageService . completionProvider . getCompleteItems (
153
153
params . position ,
154
154
) ;
155
- if ( complitionList ) {
156
- for ( const item of complitionList . items ) {
155
+ if ( completionList ) {
156
+ for ( const item of completionList . items ) {
157
157
if ( ! item . data ) {
158
158
item . data = { } ;
159
159
}
160
160
item . data . _languageService = "sas" ;
161
161
item . data . _uri = params . textDocument . uri ;
162
162
}
163
163
}
164
- return complitionList ;
164
+ return completionList ;
165
165
} ,
166
166
async python ( pyrightLanguageService ) {
167
- const complitionList = await pyrightLanguageService . onCompletion (
167
+ const completionList = await pyrightLanguageService . onCompletion (
168
168
params ,
169
169
token ,
170
170
) ;
171
- if ( complitionList ) {
171
+ if ( completionList ) {
172
+ for ( const item of completionList . items ) {
173
+ if ( ! item . data ) {
174
+ item . data = { } ;
175
+ }
176
+ item . data . _languageService = "python" ;
177
+ item . data . _uri = params . textDocument . uri ;
178
+ }
179
+
172
180
if (
173
181
params . context ?. triggerKind === CompletionTriggerKind . Invoked ||
174
182
params . context ?. triggerKind ===
175
183
CompletionTriggerKind . TriggerForIncompleteCompletions
176
184
) {
177
- if (
178
- complitionList . items . findIndex (
179
- ( item ) => item . label === "endsubmit" ,
180
- ) === - 1
181
- ) {
182
- const endsubmitItem = {
183
- insertText : undefined ,
184
- kind : CompletionItemKind . Keyword ,
185
- label : "endsubmit" ,
186
- } ;
187
- complitionList . items . push ( endsubmitItem ) ;
188
- }
189
- if (
190
- complitionList . items . findIndex (
191
- ( item ) => item . label === "endinteractive" ,
192
- ) === - 1
193
- ) {
194
- const endinteractiveItem = {
195
- insertText : undefined ,
185
+ const doc = documentPool [ params . textDocument . uri ] . document ;
186
+ const line = doc . getText ( {
187
+ start : {
188
+ line : params . position . line ,
189
+ character : 0 ,
190
+ } ,
191
+ end : params . position ,
192
+ } ) ;
193
+ if ( ! / \W / . test ( line . trimStart ( ) ) ) {
194
+ const item = {
196
195
kind : CompletionItemKind . Keyword ,
197
- label : "endinteractive" ,
196
+ data : {
197
+ _languageService : "sas" ,
198
+ _uri : params . textDocument . uri ,
199
+ } ,
198
200
} ;
199
- complitionList . items . push ( endinteractiveItem ) ;
200
- }
201
- }
202
- for ( const item of complitionList . items ) {
203
- if ( ! item . data ) {
204
- item . data = { } ;
201
+ if (
202
+ completionList . items . findIndex (
203
+ ( item ) => item . label === "endsubmit" ,
204
+ ) === - 1
205
+ ) {
206
+ completionList . items . push ( { ...item , label : "endsubmit" } ) ;
207
+ }
208
+ if (
209
+ completionList . items . findIndex (
210
+ ( item ) => item . label === "endinteractive" ,
211
+ ) === - 1
212
+ ) {
213
+ completionList . items . push ( { ...item , label : "endinteractive" } ) ;
214
+ }
205
215
}
206
- item . data . _languageService = "python" ;
207
- item . data . _uri = params . textDocument . uri ;
208
216
}
209
217
}
210
- return complitionList ;
218
+ return completionList ;
211
219
} ,
212
220
} ) ;
213
221
} ) ;
214
222
215
223
connection . onCompletionResolve ( async ( completionItem , token ) => {
216
224
const lang = completionItem . data . _languageService ;
217
- const label = completionItem . label ;
218
- const kind = completionItem . kind ;
219
- if (
220
- lang === "sas" ||
221
- ( lang === "python" &&
222
- kind === CompletionItemKind . Keyword &&
223
- [ "endsubmit" , "endinteractive" ] . includes ( label ?. toLowerCase ( ) ) )
224
- ) {
225
+ if ( lang === "sas" ) {
225
226
const languageService = getLanguageService ( completionItem . data . _uri ) ;
226
227
return await languageService . completionProvider . getCompleteItemHelp (
227
228
completionItem ,
@@ -231,9 +232,8 @@ export const runServer = (
231
232
completionItem ,
232
233
token ,
233
234
) ;
234
- } else {
235
- return completionItem ;
236
235
}
236
+ return completionItem ;
237
237
} ) ;
238
238
239
239
connection . onDocumentSymbol ( async ( params , token ) => {
0 commit comments