From 1fec37d85b1961c178b334b16090e45854f1a942 Mon Sep 17 00:00:00 2001 From: Daniel Miller Date: Sun, 31 Jan 2021 16:16:51 -0500 Subject: [PATCH] Fix: isort does not work on full document --- CHANGELOG.md | 1 + client/jsproxy.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8932b35..1e7a6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 0.3.2 - tbd +- Fix isort entire document (not selection). - Improve error handling on get command completions. - Execute all selections with "python" command. diff --git a/client/jsproxy.js b/client/jsproxy.js index 844b90f..6335cce 100644 --- a/client/jsproxy.js +++ b/client/jsproxy.js @@ -32,6 +32,10 @@ function selection(editor, pyxtrange) { return new vscode.Selection(doc.positionAt(anchor), doc.positionAt(active)) } +function allTextRange(doc) { + return doc.validateRange(new vscode.Range(0, 0, doc.lineCount, 0)) +} + /** * Interface for text manipulation on the active text editor */ @@ -64,7 +68,7 @@ const editor = { set_text: withEditor((editor, text, range, select=true) => { editor.edit(async builder => { const doc = editor.document - const rng = range ? selection(editor, range) : undefined + const rng = range ? selection(editor, range) : allTextRange(doc) await builder.replace(rng, text) let start = rng ? rng.start : doc.positionAt(0) let end = doc.positionAt(doc.offsetAt(start) + text.length)