Skip to content

Commit

Permalink
Merge pull request #1129 from BetterThanTomorrow/1120-inline-result
Browse files Browse the repository at this point in the history
Fix Inline result displaying in wrong editor
  • Loading branch information
PEZ authored Apr 18, 2021
2 parents 82cf1cb + f47e6b0 commit 1533152
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changes to Calva.
## [Unreleased]
- [Paredit backspace should delete non-bracket parts of the opening token](https://github.com/BetterThanTomorrow/calva/issues/1122)
- [Use `shift+tab` for the ”Infer parens from indentation” command](https://github.com/BetterThanTomorrow/calva/issues/1126)
- Fix: [Inline evaluation results can show up in the wrong editor](https://github.com/BetterThanTomorrow/calva/issues/1120)

## [2.0.188] - 2021-04-16
- Fix: [Getting Started REPL failing on Windows when username has spaces (on some machines)](https://github.com/BetterThanTomorrow/calva/issues/1085)
Expand Down
4 changes: 1 addition & 3 deletions src/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async function evaluateCode(code: string, options, selection?: vscode.Selection)
const filePath = options.filePath;
const session: NReplSession = options.session;
const ns = options.ns;
const editor = vscode.window.activeTextEditor;

if (code.length > 0) {
let err: string[] = [];
Expand All @@ -79,7 +80,6 @@ async function evaluateCode(code: string, options, selection?: vscode.Selection)
outputWindow.append(value, (resultLocation) => {
if (selection) {
const c = selection.start.character;
const editor = vscode.window.activeTextEditor;
if (options.replace) {
const indent = `${' '.repeat(c)}`,
edit = vscode.TextEdit.replace(selection, value.replace(/\n/gm, "\n" + indent)),
Expand Down Expand Up @@ -112,7 +112,6 @@ async function evaluateCode(code: string, options, selection?: vscode.Selection)
const outputWindowError = err.length ? `; ${normalizeNewLinesAndJoin(err, true)}` : formatAsLineComments(e);
outputWindow.append(outputWindowError, async (resultLocation, afterResultLocation) => {
if (selection) {
const editor = vscode.window.activeTextEditor;
const editorError = util.stripAnsi(err.length ? err.join("\n") : e);
const currentCursorPos = editor.selection.active;
if (!outputWindow.isResultsDoc(editor.document)) {
Expand Down Expand Up @@ -142,7 +141,6 @@ async function evaluateSelection(document: {}, options) {

if (getStateValue('connected')) {
const editor = vscode.window.activeTextEditor;
const selection = editor.selection;
let code = "";
let codeSelection: vscode.Selection;
state.analytics().logEvent("Evaluation", "selectionFn").send();
Expand Down

0 comments on commit 1533152

Please sign in to comment.