File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,13 @@ export class ClojureCompletionItemProvider implements vscode.CompletionItemProvi
23
23
if ( ! cljConnection . isConnected ( ) )
24
24
return Promise . reject ( 'No nREPL connected.' ) ;
25
25
26
- // TODO: Use VSCode means for getting a current word
27
- let lineText = document . lineAt ( position . line ) . text ;
28
- let words : string [ ] = lineText . split ( ' ' ) ;
29
- let currentWord = words [ words . length - 1 ] . replace ( / ^ [ \( ' \[ \{ ] + | [ \) \] \} ] + $ / g, '' ) ;
30
- let text = document . getText ( )
31
- let ns = cljParser . getNamespace ( text ) ;
26
+ const wordRange = document . getWordRangeAtPosition ( position ) ;
27
+ if ( ! wordRange )
28
+ return Promise . reject ( 'No word selected.' ) ;
32
29
33
- let currentWordLength : number = currentWord . length ;
30
+ const line = document . lineAt ( position . line ) ,
31
+ currentWord = line . text . slice ( wordRange . start . character , wordRange . end . character ) ,
32
+ ns = cljParser . getNamespace ( document . getText ( ) ) ;
34
33
35
34
let buildInsertText = ( suggestion : string ) => {
36
35
return suggestion [ 0 ] === '.' ? suggestion . slice ( 1 ) : suggestion ;
You can’t perform that action at this time.
0 commit comments