Skip to content

Commit

Permalink
Stop using non-existing model selection accessors
Browse files Browse the repository at this point in the history
TODO: Tighten up the tsconfig so that bugs that this do not build.

Fixes #519
  • Loading branch information
PEZ committed Dec 13, 2019
1 parent b1153e8 commit 22fbb52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Changes to Calva.

## [Unreleased]
- Fix: [autocompletion in REPL window broken](https://github.com/BetterThanTomorrow/calva/issues/519)

## [2.0.70] - 2019-12-12
- Fix (well, improving, at least): [REPL Window not accepting keys like cursor, return, etcetera](https://github.com/BetterThanTomorrow/calva/issues/516)
- Fix: [REPL Window not accepting keys like cursor, return, etcetera](https://github.com/BetterThanTomorrow/calva/issues/516)

## [2.0.69] - 2019-12-12
- Fix: [Prepare for Fix of Webview editor font size bug](https://github.com/microsoft/vscode/commit/7e2d7965e5d5728c53996f0024be9b0681369b2a)
Expand Down
13 changes: 7 additions & 6 deletions src/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,25 +272,26 @@ window.addEventListener("keydown", e => {
e.preventDefault();
}
if (e.keyCode == 9 || e.keyCode == 13) { // tab or enter
let tk = con.readline.getTokenCursor(con.readline.selectionEnd, true)
const [oldLeft, oldRight] = [con.readline.selectionLeft, con.readline.selectionRight]
let tk = con.readline.getTokenCursor(oldRight, true)
if (tk.isWhiteSpace())
tk.previous();
let start = tk.offsetStart
let end = tk.offsetEnd;
con.readline.withUndo(() => {
con.readline.model.edit([
new ModelEdit('changeRange', [start, end, completions[selectedCompletion]])
new ModelEdit('changeRange', [start, end, completions[selectedCompletion], [oldRight, oldRight], [end, end]])
], {});
});
con.readline.selectionStart = con.readline.selectionEnd = start + completions[selectedCompletion].length;
con.readline.selection = new ModelEditSelection(start + completions[selectedCompletion].length);
docDiv.style.visibility = "hidden";
completionDiv.style.visibility = "hidden";
completions = [];
con.readline.repaint();
e.stopImmediatePropagation();
e.preventDefault();
}
} else {
} else {[con.readline.selectionLeft, con.readline.selectionRight]
if (e.keyCode == 0x20 && e.ctrlKey) {
con.readline.maybeShowCompletion();
e.stopImmediatePropagation()
Expand Down Expand Up @@ -343,7 +344,7 @@ function restorePrompt() {
con.requestPrompt(ns + "=> ");
if (originalText) {
con.setText(originalText);
[con.readline.selectionStart, con.readline.selectionEnd] = [selectionStart, selectionEnd];
con.readline.selection = new ModelEditSelection(selectionStart, selectionEnd);
con.readline.repaint();
selectionStart = selectionEnd = 0;
originalText = null;
Expand Down Expand Up @@ -489,7 +490,7 @@ function runEvaluation(ns: string, form: string) {
if (con.readline && ns && form) {
con.readline.promptElem.textContent = ns + "=> ";
originalText = con.readline.model.getText(0, con.readline.model.maxOffset);
[selectionStart, selectionEnd] = [con.readline.selectionStart, con.readline.selectionEnd];
[selectionStart, selectionEnd] = [con.readline.selectionLeft, con.readline.selectionRight];
con.setText(form);
con.submitLine(true);
}
Expand Down

0 comments on commit 22fbb52

Please sign in to comment.