@@ -148,80 +148,81 @@ export const runServer = (
148148 ) {
149149 return undefined ;
150150 }
151- const complitionList =
151+ const completionList =
152152 await languageService . completionProvider . getCompleteItems (
153153 params . position ,
154154 ) ;
155- if ( complitionList ) {
156- for ( const item of complitionList . items ) {
155+ if ( completionList ) {
156+ for ( const item of completionList . items ) {
157157 if ( ! item . data ) {
158158 item . data = { } ;
159159 }
160160 item . data . _languageService = "sas" ;
161161 item . data . _uri = params . textDocument . uri ;
162162 }
163163 }
164- return complitionList ;
164+ return completionList ;
165165 } ,
166166 async python ( pyrightLanguageService ) {
167- const complitionList = await pyrightLanguageService . onCompletion (
167+ const completionList = await pyrightLanguageService . onCompletion (
168168 params ,
169169 token ,
170170 ) ;
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+
172180 if (
173181 params . context ?. triggerKind === CompletionTriggerKind . Invoked ||
174182 params . context ?. triggerKind ===
175183 CompletionTriggerKind . TriggerForIncompleteCompletions
176184 ) {
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 = {
196195 kind : CompletionItemKind . Keyword ,
197- label : "endinteractive" ,
196+ data : {
197+ _languageService : "sas" ,
198+ _uri : params . textDocument . uri ,
199+ } ,
198200 } ;
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+ }
205215 }
206- item . data . _languageService = "python" ;
207- item . data . _uri = params . textDocument . uri ;
208216 }
209217 }
210- return complitionList ;
218+ return completionList ;
211219 } ,
212220 } ) ;
213221 } ) ;
214222
215223 connection . onCompletionResolve ( async ( completionItem , token ) => {
216224 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" ) {
225226 const languageService = getLanguageService ( completionItem . data . _uri ) ;
226227 return await languageService . completionProvider . getCompleteItemHelp (
227228 completionItem ,
@@ -231,9 +232,8 @@ export const runServer = (
231232 completionItem ,
232233 token ,
233234 ) ;
234- } else {
235- return completionItem ;
236235 }
236+ return completionItem ;
237237 } ) ;
238238
239239 connection . onDocumentSymbol ( async ( params , token ) => {
0 commit comments