Skip to content

Commit

Permalink
Fix completion at the middle of a line (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
abogoyavlensky authored and avli committed Nov 9, 2019
1 parent 429899b commit 21a5711
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/clojureSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ export class ClojureCompletionItemProvider implements vscode.CompletionItemProvi
if (!cljConnection.isConnected())
return Promise.reject('No nREPL connected.');

// TODO: Use VSCode means for getting a current word
let lineText = document.lineAt(position.line).text;
let words: string[] = lineText.split(' ');
let currentWord = words[words.length - 1].replace(/^[\('\[\{]+|[\)\]\}]+$/g, '');
let text = document.getText()
let ns = cljParser.getNamespace(text);
const wordRange = document.getWordRangeAtPosition(position);
if (!wordRange)
return Promise.reject('No word selected.');

let currentWordLength: number = currentWord.length;
const line = document.lineAt(position.line),
currentWord = line.text.slice(wordRange.start.character, wordRange.end.character),
ns = cljParser.getNamespace(document.getText());

let buildInsertText = (suggestion: string) => {
return suggestion[0] === '.' ? suggestion.slice(1) : suggestion;
Expand Down

0 comments on commit 21a5711

Please sign in to comment.