Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the REPL/output with cursor at the bottom (#792) #793

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Changes to Calva.

## [Unreleased]
- Fix: [Show the REPL/output with cursor at the bottom](https://github.com/BetterThanTomorrow/calva/issues/792)
- [Fix: evals should be ignored during parsing](https://github.com/BetterThanTomorrow/calva/issues/763)
- Fix: [Test runner can't find tests under cursor when using a custom test macro](https://github.com/BetterThanTomorrow/calva/issues/786)

Expand Down
20 changes: 5 additions & 15 deletions src/results-output/results-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export async function openResultsDoc(): Promise<vscode.TextDocument> {

export function revealResultsDoc(preserveFocus: boolean = true) {
openResultsDoc().then(doc => {
vscode.window.showTextDocument(doc, getViewColumn(), preserveFocus);
vscode.window.showTextDocument(doc, getViewColumn(), preserveFocus).then(editor => {
util.scrollToBottom(editor);
})
});
}

Expand Down Expand Up @@ -206,7 +208,6 @@ export function appendCurrentTopLevelForm() {
appendFormGrabbingSessionAndNS(true);
}

let scrollToBottomSub: vscode.Disposable;
interface OnAppendedCallback {
(insertLocation: vscode.Location): any
}
Expand All @@ -231,27 +232,16 @@ export function append(text: string, onAppended?: OnAppendedCallback): void {
const currentContent = doc.getText();
const lastLineEmpty = currentContent.match(/\n$/) || currentContent === '';
const appendText = `${lastLineEmpty ? '' : '\n'}${ansiStrippedText}\n`;

insertPosition = doc.positionAt(Infinity);
edit.insert(DOC_URI(), insertPosition, `${appendText}`);
if (scrollToBottomSub) {
scrollToBottomSub.dispose();
}

let visibleResultsEditors: vscode.TextEditor[] = [];
vscode.window.visibleTextEditors.forEach(editor => {
if (isResultsDoc(editor.document)) {
visibleResultsEditors.push(editor);
}
});
if (visibleResultsEditors.length == 0) {
scrollToBottomSub = vscode.window.onDidChangeActiveTextEditor((editor) => {
if (isResultsDoc(editor.document)) {
util.scrollToBottom(editor);
scrollToBottomSub.dispose();
}
});
state.extensionContext.subscriptions.push(scrollToBottomSub);
}

vscode.workspace.applyEdit(edit).then(success => {
applyingEdit = false;
doc.save();
Expand Down