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

PROPOSAL enhance REPL window handling #422

Merged
merged 102 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
a81b6bb
Update changelog with 2.0.38
PEZ Sep 14, 2019
3eeb4fd
Prepare for v2.0.39
PEZ Sep 14, 2019
987ce42
Use shadow-cljs 2.8.52
PEZ Sep 15, 2019
c38b346
Add note about Parinfer extension conflicts
PEZ Sep 15, 2019
27efd45
Add note about testing not working with cljs
PEZ Sep 15, 2019
607d1e2
Merged master from upstream.
Sep 28, 2019
c9d5f2d
Merged from upstream master.
Sep 29, 2019
74da2fa
Merge branch 'master' of github.com:cfehse/calva
Sep 29, 2019
7ac3196
Merged master from upstream
Sep 30, 2019
bf3efb6
Merge branch 'master' of https://github.com/BetterThanTomorrow/calva
Oct 4, 2019
6b07bce
Merge branch 'master' of https://github.com/BetterThanTomorrow/calva
Oct 6, 2019
ebff7b2
Merge HEAD, branch 'master' of https://github.com/BetterThanTomorrow/…
Oct 11, 2019
fa0f9d5
Merged dev from upstream
Oct 11, 2019
f1519a0
Merge HEAD, branch 'dev' of https://github.com/BetterThanTomorrow/calva
Oct 12, 2019
2b9f19c
Merge HEAD, branch 'dev' of github.com:BetterThanTomorrow/calva into dev
Oct 16, 2019
1f07945
Merge branch 'dev' of github.com:cfehse/calva into dev
Oct 16, 2019
bf486d2
Merge branch 'dev' of github.com:cfehse/calva into dev
Oct 17, 2019
3f0f1a4
Merge branch 'dev' of github.com:BetterThanTomorrow/calva into dev
Oct 18, 2019
0a72f7f
Merge branch 'dev' of github.com:cfehse/calva into dev
Oct 18, 2019
897b960
Merge HEAD, branch 'master' of github.com:BetterThanTomorrow/calva
Oct 18, 2019
225d572
Link Tao of Calva from README
PEZ Oct 18, 2019
3f9477e
Wiki Home is now Tao Home
PEZ Oct 18, 2019
9193fd9
Merge branch 'wip/tao' [skip ci]
PEZ Oct 18, 2019
8dc1ee2
Merge HEAD, branch 'dev' of https://github.com/BetterThanTomorrow/cal…
Oct 19, 2019
815778f
Merge branch 'dev' of github.com:cfehse/calva into dev
Oct 19, 2019
fbcc7dd
Merge HEAD, branch 'master' of https://github.com/BetterThanTomorrow/…
Oct 19, 2019
2af6e40
Merge branch 'dev' of github.com:cfehse/calva
Oct 19, 2019
3371027
Merge branch 'dev' of https://github.com/BetterThanTomorrow/calva int…
Oct 19, 2019
a5f9bde
Merge branch 'master' of github.com:cfehse/calva into dev
Oct 19, 2019
516cf26
Merge branch 'dev' of https://github.com/BetterThanTomorrow/calva int…
Oct 20, 2019
acb4a2e
Merge branch 'master' of github.com:cfehse/calva into dev
Oct 20, 2019
85009f3
Removed linter warnings by adding catch handlers.
Oct 20, 2019
19bafca
Moved repl window creation to function. Error handling improved.
Oct 20, 2019
8a4ca75
Improved NReplEvaluation class.
Oct 20, 2019
4bf5cad
Added clear commands for repl windows improved reconnect.
Oct 20, 2019
bee97c4
Make a more real test of the repl and include error to reconnect.
Oct 20, 2019
e1d25ab
Get the stacktrace before resolve.
Oct 20, 2019
e594c04
Get the stacktrace from the evaluation.
Oct 20, 2019
cd84a87
Merge branch 'dev' of https://github.com/BetterThanTomorrow/calva int…
Oct 21, 2019
0d53cf5
Merge branch 'dev' into wip/enhance-repl-window-handling
Oct 21, 2019
947fc2a
Merged dev from upstream.
Oct 21, 2019
5006d6f
Incorporated rudimentary chances for user input from PR #419.
Oct 21, 2019
f6b1cf2
Only add entries to history if they do not exist.
Oct 21, 2019
7b2aeb2
Added stdin property to retrieve user input.
Oct 22, 2019
ec5e31e
Support user input from the repl window.
Oct 22, 2019
7e5722d
Dummy implementation for 'user-input'.
Oct 22, 2019
284cc1e
Set exception and stacktrace on interrupt.
Oct 22, 2019
3da5323
Made interruption of eval robust.
Oct 22, 2019
4b77f07
Added simple user input.
Oct 22, 2019
d9568f2
Added styling to the user input.
Oct 22, 2019
b7e4ebb
Do not produce further output if interrupted.
Oct 23, 2019
e7d1502
Implemented in place clear command.
Oct 23, 2019
8541d66
Added info about ctrl+d to interrupt.
Oct 23, 2019
33b1b49
Merge branch 'dev' of https://github.com/BetterThanTomorrow/calva int…
Oct 23, 2019
1979142
Merge branch 'dev' into wip/enhance-repl-window-handling
Oct 23, 2019
25fc501
Preserve the input from the input element.
Oct 23, 2019
0b684cb
Merge branch 'dev' into wip/enhance-repl-window-handling
PEZ Oct 24, 2019
0056b9e
Support stdin for editor repl
PEZ Oct 24, 2019
3756a88
Merge branch 'dev'
PEZ Oct 24, 2019
54f0c14
Made evaluation interruption robust.
Oct 25, 2019
e678624
Made evaluation interrupt reject the promise.
Oct 25, 2019
48eede7
Removed unused async/waits,
Oct 25, 2019
a4a7af8
Removed unused class.
Oct 25, 2019
124795e
Added "Interrupt running Evaluations" command.
Oct 25, 2019
06c4f29
fix typo
rogererens Oct 25, 2019
9ba9bd7
Made history add equal on both sides.
Oct 25, 2019
36a3c0c
Corrected history commands.
Oct 25, 2019
a7ada3c
Merged changes from upstream branch.
Oct 25, 2019
5e24798
Merge HEAD, branch 'dev' of https://github.com/BetterThanTomorrow/cal…
Oct 25, 2019
30c243a
Merge branch 'dev' into wip/enhance-repl-window-handling
Oct 25, 2019
c118d46
Merge pull request #429 from rogererens/patch-1
PEZ Oct 25, 2019
0780eb4
Fix typo
rogererens Oct 25, 2019
f538048
Fix typo
rogererens Oct 25, 2019
99f3de4
Merge pull request #430 from rogererens/patch-2
PEZ Oct 26, 2019
ea4fcc7
Merge pull request #431 from rogererens/patch-1
PEZ Oct 26, 2019
53d766a
Group eval related commands together
PEZ Oct 26, 2019
7072381
Collect msg in the default handler. Add session registry.
Oct 26, 2019
331c7dc
Added session registry to interrupt left over running code.
Oct 26, 2019
529aeed
Merge branch 'wip/enhance-repl-window-handling' of https://github.com…
Oct 26, 2019
f2089a1
Merge HEAD, branch 'dev' of https://github.com/BetterThanTomorrow/cal…
Oct 26, 2019
060dd8f
Merge branch 'dev' into wip/enhance-repl-window-handling
Oct 26, 2019
b2390b1
Update change log
PEZ Oct 26, 2019
0f0080a
Rename window clearing commands
PEZ Oct 26, 2019
b1f0387
Prepare for v2.0.54
PEZ Oct 24, 2019
e302af5
Throwing out all linting code, bundling
PEZ Oct 24, 2019
d1649d6
Update changelog unreleased
PEZ Oct 24, 2019
d679a08
Speling and remove old clj-kondo windows reference
PEZ Oct 24, 2019
3d8b5c0
Remove confusion about qualified symbols
PEZ Oct 25, 2019
e8c9b11
Mention linting early in the docs
PEZ Oct 25, 2019
ba6175e
Add info for Windows users
PEZ Oct 25, 2019
b1576fb
Add missing link markup [skip ci]
PEZ Oct 25, 2019
5b0d85e
Add link to clj-kondo npm windows info
PEZ Oct 25, 2019
ef854b6
Update changelog for release of v2.0.54 [skip ci]
PEZ Oct 25, 2019
4ad4f25
Merge HEAD, branch 'dev' of https://github.com/BetterThanTomorrow/cal…
Oct 27, 2019
9ce3428
Merge branch 'dev' into wip/enhance-repl-window-handling
Oct 27, 2019
892d9e4
Made async output in repl window as undisturbing as possible.
Oct 27, 2019
f87501e
Added repl type to async prefix for the output channel.
Oct 27, 2019
75bf6d7
Removed fantasy feature from the change log
PEZ Oct 27, 2019
2a69c02
Resolve PR merge conflicts
PEZ Oct 27, 2019
2d08a2c
Make the 'none' view default for stack traces in repl window.
Oct 27, 2019
e1fe768
Merge branch 'wip/enhance-repl-window-handling' of https://github.com…
Oct 27, 2019
5438707
Add stacktrace change to the log, and bump version
PEZ Oct 27, 2019
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
Changes to Calva.

## [Unreleased]
- [Fix floating promises](https://github.com/BetterThanTomorrow/calva/issues/411)
- [Add commands for interrupting the current evaluation as well as all running evaluations](https://github.com/BetterThanTomorrow/calva/issues/237)
- [Calva asks for user input when `stdin` needs it (e.g. `read-line`)](https://github.com/BetterThanTomorrow/calva/issues/377)
- Command for clearing the REPL history reworked and now also ”restarts” the REPL window.
- Commands are now added to REPL window history only if they are not identical to the previous command on the history stack.
- [Fix floating promises in evelauation module](https://github.com/BetterThanTomorrow/calva/issues/411)
- REPL Window Evaluation errors now initially hide the stack trace. The user can show it with a click.

## [2.0.54] - 2019-10-25
- [Stop linting, start bundling clj-kondo](https://github.com/BetterThanTomorrow/calva/issues/423)
Expand Down
14 changes: 14 additions & 0 deletions assets/styles/webview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ img {
}
}

.userinput {
color: var(--vscode-editor-foreground);
background-color: var(--vscode-editor-background);
font-family: var(--vscode-editor-font-family);
font-size: var(--vscode-editor-font-size);
font-weight: var(--vscode-editor-font-weight);
border: none;
padding-top: 5px;
}

input[class*="userinput"]:focus {
outline: none;
}

.output {
white-space: pre;
color: var(--vscode-editorWarning-foreground);
Expand Down
5 changes: 3 additions & 2 deletions assets/webview.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ <h3>Calva REPL – Powered by <a href="https://github.com/clojure-emacs/orchard"
<!-- <p id="motd"></p> -->
<p>The REPL prompt is a multiline, Paredit powered, Clojure editor. Some useful shortcuts are:
<ul>
<li><code>alt+up/down</code>: for history navigation</li>
<li><code>alt+enter</code>: to submit the current line</li>
<li><code>alt+up/down</code>&nbsp; for history navigation</li>
<li><code>alt+enter</code>&nbsp; to submit the current line</li>
<li><code>ctrl+d</code>&nbsp; to interrupt a running evaluation</li>
</ul>
</p>
<p><strong>NB:</strong> Make it a habit to start any Calva session by loading a file. Many things do not work before that is done. Use <code>ctrl+alt+c enter</code> in the code editor to load (evaluate) the active file.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/source/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The recommended way is to:

This way Calva can make sure it is started with the dependencies needed for a working Clojure and/or ClojureScript session. This is often referred to as **Jack in** (because that is what it is called in CIDER).

Jack-in supports both CLJ and for CLJS, and has built-in configurations for **Leiningen**, **Clojure CLI**, and **shadow-cljs** projects, as well as for the CLJS repl types: **Figwheel Main**, **lein-fiwgheel** (legacy Figwheel), **shadow-cljs**, and Nashorn. Using jack-in provides your development environment with all the dependencies you need for Calva to work.
Jack-in supports both CLJ and for CLJS, and has built-in configurations for **Leiningen**, **Clojure CLI**, and **shadow-cljs** projects, as well as for the CLJS repl types: **Figwheel Main**, **lein-figwheel** (legacy Figwheel), **shadow-cljs**, and Nashorn. Using jack-in provides your development environment with all the dependencies you need for Calva to work.

It works like so:

Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/source/finding-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Now might be a good time to see [Calva Top 10 Commands](commands-top10.md)

Did you know? There is a complete list of Calva settings and commands in the *Contributions* tab of the Calva entry in the *Extensions* pane in VS Code.

![The Clava Contributions Tab](https://user-images.githubusercontent.com/30010/66733740-c754b800-ee60-11e9-877b-962f6b920cd7.png)
![The Calva Contributions Tab](https://user-images.githubusercontent.com/30010/66733740-c754b800-ee60-11e9-877b-962f6b920cd7.png)
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 55 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,14 @@
"category": "Calva"
},
{
"command": "calva.clearREPLWindowHistory",
"title": "Clear history of active REPL window (mainly in case it has been borked)",
"command": "calva.clearClojureREPLWindow",
"title": "Clear Clojure REPL Window + History",
"enablement": "calva:connected",
"category": "Calva"
},
{
"command": "calva.clearClojureScriptREPLWindow",
"title": "Clear ClojureScript REPL Window + History",
"enablement": "calva:connected",
"category": "Calva"
},
Expand All @@ -613,6 +619,12 @@
"title": "Clear Inline Evaluation Results",
"category": "Calva"
},
{
"command": "calva.interruptAllEvaluations",
"title": "Interrupt running Evaluations",
"enablement": "calva:connected",
"category": "Calva"
},
{
"command": "calva.evaluateSelection",
"title": "Evaluate Current Form",
Expand Down Expand Up @@ -995,6 +1007,10 @@
"key": "ctrl+alt+c e",
"win": "ctrl+alt+c v"
},
{
"command": "calva.interruptAllEvaluations",
"key": "ctrl+alt+c ctrl+alt+d"
},
{
"command": "calva.evaluateCurrentTopLevelForm",
"key": "ctrl+alt+c space"
Expand Down Expand Up @@ -1300,6 +1316,18 @@
"when": "false"
}
],
"editor/title": [
{
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.loadFile",
"group": "calva/b-eval"
},
{
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.loadNamespace",
"group": "calva/b-eval"
}
],
"editor/context": [
{
"when": "editorLangId == clojure && !calva:connected",
Expand All @@ -1309,65 +1337,70 @@
{
"when": "editorLangId == clojure && calva:connected",
"command": "calva.disconnect",
"group": "calva/x-disconnect"
},
{
"when": "editorLangId == clojure",
"command": "calva.togglePrettyPrint",
"group": "calva/y-toggle"
"group": "calva/x-connect"
},
{
"when": "editorLangId == clojure",
"command": "calva.selectCurrentForm",
"group": "calva/a-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.loadFile",
"group": "calva/b-eval"
},
{
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.loadNamespace",
"group": "calva/b-eval"
},
{
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.evaluateSelection",
"group": "calva/b-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.evaluateCurrentTopLevelForm",
"group": "calva/b-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.evaluateSelectionAsComment",
"group": "calva/b-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.evaluateTopLevelFormAsComment",
"group": "calva/b-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"command": "calva.loadFile",
"group": "calva/c-load"
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.interruptAllEvaluations",
"group": "calva/b-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"command": "calva.loadNamespace",
"group": "calva/c-load"
"when": "editorLangId == clojure",
"command": "calva.togglePrettyPrint",
"group": "calva/b-eval"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.runAllTests",
"group": "calva/d-test"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.runNamespaceTests",
"group": "calva/d-test"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.rerunTests",
"group": "calva/d-test"
},
{
"when": "editorLangId == clojure && calva:connected",
"enablement": "editorLangId == clojure && calva:connected",
"command": "calva.runTestUnderCursor",
"group": "calva/d-test"
}
Expand Down
52 changes: 27 additions & 25 deletions src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ import { NReplClient, NReplSession } from "./nrepl";
import { reconnectReplWindow, openReplWindow, sendTextToREPLWindow, createReplWindow } from './repl-window';
import { CljsTypeConfig, ReplConnectSequence, getDefaultCljsType, CljsTypes, askForConnectSequence } from './nrepl/connectSequence';

function createAndConnectReplWindow(session: NReplSession, mode: "clj" | "cljs", ) {

createReplWindow(session, mode).then(() => {
openReplWindow(mode, true).then(() => {
reconnectReplWindow(mode).then(() => {
}).catch(e => {
console.error(`Failed reconnecting ${mode} REPL window: `, e);
});
}).catch(e => {
console.error(`Failed to open ${mode} REPL window: `, e);
})
}).catch((e) => {
console.error(`Failed to create ${mode} REPL window: `, e);
});
}

async function connectToHost(hostname, port, connectSequence: ReplConnectSequence) {
state.analytics().logEvent("REPL", "Connecting").send();

Expand All @@ -38,27 +54,19 @@ async function connectToHost(hostname, port, connectSequence: ReplConnectSequenc
})
cljSession = nClient.session;
chan.appendLine("Connected session: clj");
openReplWindow("clj", true).then( window => {
reconnectReplWindow("clj").catch(reason => {
console.error("Failed reconnecting REPL window: ", reason);
});
}).catch(e => {});

util.setConnectingState(false);
util.setConnectedState(true);
state.analytics().logEvent("REPL", "ConnectedCLJ").send();
state.cursor.set('clj', cljSession)
state.cursor.set('cljc', cljSession)
status.update();


createAndConnectReplWindow(cljSession, "clj");
if (connectSequence.afterCLJReplJackInCode) {
state.outputChannel().appendLine("Evaluating `afterCLJReplJackInCode` in CLJ REPL Window");
await sendTextToREPLWindow("clj", connectSequence.afterCLJReplJackInCode, null, false);
}

//cljsSession = nClient.session;
//terminal.createREPLTerminal('clj', null, chan);
let cljsSession = null,
cljsBuild = null;
try {
Expand All @@ -70,15 +78,14 @@ async function connectToHost(hostname, port, connectSequence: ReplConnectSequenc
[cljsSession, cljsBuild] = await makeCljsSessionClone(cljSession, translatedReplType, connectSequence.name);
state.analytics().logEvent("REPL", "ConnectCljsRepl", isBuiltinType ? connectSequence.cljsType as string: "Custom").send();
}
if (cljsSession) {
await setUpCljsRepl(cljsSession, chan, cljsBuild);
}
chan.appendLine('cljc files will use the clj REPL.' + (cljsSession ? ' (You can toggle this at will.)' : ''));
} catch (e) {
chan.appendLine("Error while connecting cljs REPL: " + e);
}
if (cljsSession)
await setUpCljsRepl(cljsSession, chan, cljsBuild);
chan.appendLine('cljc files will use the clj REPL.' + (cljsSession ? ' (You can toggle this at will.)' : ''));
//evaluate.loadFile();
status.update();

} catch (e) {
util.setConnectingState(false);
util.setConnectedState(false);
Expand All @@ -90,16 +97,11 @@ async function connectToHost(hostname, port, connectSequence: ReplConnectSequenc
return true;
}

async function setUpCljsRepl(cljsSession, chan, build) {
state.cursor.set("cljs", cljsSession);
chan.appendLine("Connected session: cljs" + (build ? ", repl: " + build : ""));
await createReplWindow(cljsSession, "cljs");
openReplWindow("cljs", true).then( window => {
reconnectReplWindow("cljs").catch(reason => {
console.error("Failed reconnecting REPL window: ", reason);
});
}).catch(e => {});
async function setUpCljsRepl(session, chan, build) {
state.cursor.set("cljs", session);
status.update();
chan.appendLine("Connected session: cljs" + (build ? ", repl: " + build : ""));
createAndConnectReplWindow(session, "cljs");
}

function getFigwheelMainBuilds() {
Expand Down Expand Up @@ -273,7 +275,7 @@ function createCLJSReplType(cljsType: CljsTypeConfig, cljsTypeName: string, conn
}
}

if (build != null) {
if ((typeof build == 'string') && build != "") {
initCode = updateInitCode(build, initCode);
if (!initCode) {
//TODO error message
Expand Down Expand Up @@ -475,7 +477,7 @@ function standaloneConnect(connectSequence: ReplConnectSequence, chan: vscode.Ou
const cljsTypeName = projectTypes.getCljsTypeName(connectSequence);
chan.appendLine(`Connecting ...`);
state.analytics().logEvent("REPL", "StandaloneConnect", `${connectSequence.name} + ${cljsTypeName}`).send();
connect(connectSequence, false, false);
connect(connectSequence, false, false).catch( () => { } );
}
else {
chan.appendLine("Aborting connect, error determining connect sequence.");
Expand Down
Loading