Fork me on GitHub

Hello, I have been using Calva for a few weeks now and I'm really liking it. I used to use Vim+fireplace but I'm using vscode more and more so I wanted a clojure environment there as well. Nice job!


I also noticed failures with selecCurrentForm, so I cloned the repo, and after some tinkering and debugging, I found the problem and fixed it.


It was a type mismatch on select.ts


Details below


diff --git a/calva/repl/middleware/select.ts b/calva/repl/middleware/select.ts index d4278dd..d1054ec 100644 --- a/calva/repl/middleware/select.ts +++ b/calva/repl/middleware/select.ts @@ -28,7 +28,7 @@ function adjustRangeIgnoringComment(doc, range) { } -function getFormSelection(doc, pos, topLevel) { +function getFormSelection(doc, pos, topLevel) : vscode.Range { let allText = doc.getText(), ast = paredit.parse(allText), idx = doc.offsetAt(pos), @@ -42,13 +42,12 @@ function getFormSelection(doc, pos, topLevel) { function selectCurrentForm(document = {}) { let editor = vscode.window.activeTextEditor, doc = util.getDocument(document), - selection = editor.selection, - codeSelection = null; + selection = editor.selection; if (selection.isEmpty) { - codeSelection = getFormSelection(doc,, false); + let codeSelection = getFormSelection(doc,, false); if (codeSelection) { - editor.selection = codeSelection; + editor.selection = new vscode.Selection(codeSelection.start, codeSelection.end); } } }


I want to contribute the fix if it is OK, but I have never done a pull request before. I will read on how to do it but bear with me if I do not get it right the first time.


Nice! Thanks!!


Done. I created a pull request for review. Thanks.


Great, @martinbertolino. Many thanks again. I asked a question about the PR on Github. Check it out, please.


Since you told me this is your first PR, maybe you don’t know how easy it is to amend it. You just push towards the branch in your fork and the PR will be updated as long as it hasn’t been pulled.


@pez, new PR ready for review. Thanks again!


Super! Late here now. Will pull it tomorrow. Happy to get help with Calva!