diff --git a/CHANGELOG.md b/CHANGELOG.md index f4ea14e80..2e89fc571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes to Calva. - [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) +- [Bring back results in hovers](https://github.com/BetterThanTomorrow/calva/issues/736) ## [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) diff --git a/docs/site/output.md b/docs/site/output.md index 57d85c9a9..37488e25e 100644 --- a/docs/site/output.md +++ b/docs/site/output.md @@ -63,21 +63,6 @@ If you have typed some text after the prompt before you start traversing up the You can clear the repl history by running the command "Clear REPL History" from the command palette. -## Peek at Results - -On smaller screens (or just depending on your taste) you might not have the output window visible side-by-side with your code, but rather in a tab in the same editor group. - -Then your immediate feedback will be the inline display, which is limited to the first line of the results. All is not lost, however, you can peek at the full results using VS Code's command **Peek Definition**. Calva adds a definition pointer ”in” to the evaluated code in the output window. - -![Peek at results](images/howto/output/peek-last-result.gif) - -(On Mac the default keyboard shortcut for the peek command is `alt+f12`.) - -In the demo gif we utilize two things about this peek widget: - -1. It stays open until you close it. So you can keep evaluating different versions of your form and see the results get printed. -2. The widget displays a ”full” Calva editor, so you can use Paredit to conveniently select forms. - ## Stack Traces When an evaluation produces an error, the output window will automatically print the the error message. If there is a stack trace associated with the error, this can now be printed on demand using the **Calva: Print Last Stacktrace to the Output Window** command. The output window will also have a Codelense button below the error message that will print the stack trace.. diff --git a/src/extension.ts b/src/extension.ts index ee55b2b0c..985ff7e12 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -178,6 +178,7 @@ async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand('calva.runAllTests', testRunner.runAllTestsCommand)); context.subscriptions.push(vscode.commands.registerCommand('calva.rerunTests', testRunner.rerunTestsCommand)); context.subscriptions.push(vscode.commands.registerCommand('calva.clearInlineResults', annotations.clearEvaluationDecorations)); + context.subscriptions.push(vscode.commands.registerCommand('calva.copyAnnotationHoverText', annotations.copyHoverTextCommand)); context.subscriptions.push(vscode.commands.registerCommand('calva.copyLastResults', eval.copyLastResultCommand)); context.subscriptions.push(vscode.commands.registerCommand('calva.requireREPLUtilities', eval.requireREPLUtilitiesCommand)); context.subscriptions.push(vscode.commands.registerCommand('calva.refresh', refresh.refresh)); @@ -222,7 +223,6 @@ async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.languages.registerHoverProvider(config.documentSelector, new HoverProvider())); context.subscriptions.push(vscode.languages.registerDefinitionProvider(config.documentSelector, new definition.ClojureDefinitionProvider())); context.subscriptions.push(vscode.languages.registerDefinitionProvider(config.documentSelector, new definition.StackTraceDefinitionProvider())); - context.subscriptions.push(vscode.languages.registerDefinitionProvider(config.documentSelector, new definition.ResultsDefinitionProvider())); context.subscriptions.push(vscode.languages.registerSignatureHelpProvider(config.documentSelector, new CalvaSignatureHelpProvider(), ' ', ' ')); diff --git a/src/providers/annotations.ts b/src/providers/annotations.ts index bbb525d1b..bba1a4450 100644 --- a/src/providers/annotations.ts +++ b/src/providers/annotations.ts @@ -139,9 +139,11 @@ function decorateSelection(resultString: string, codeSelection: vscode.Selection decorationRanges = _.filter(decorationRanges, (o) => { return !o.range.intersection(codeSelection) }); decoration["range"] = codeSelection; if (status != AnnotationStatus.PENDING && status != AnnotationStatus.REPL_WINDOW) { - const commandUri = `command:calva.showOutputWindow`, - commandMd = `[Open Results Window](${commandUri} "Open the results window")`; - let hoverMessage = new vscode.MarkdownString(commandMd); + const copyCommandUri = `command:calva.copyAnnotationHoverText?${encodeURIComponent(JSON.stringify([{ text: resultString }]))}`, + copyCommandMd = `[Copy](${copyCommandUri} "Copy results to the clipboard")`; + const openWindowCommandUri = `command:calva.showOutputWindow`, + openWindowCommandMd = `[Open Output Window](${openWindowCommandUri} "Open the output window")`; + const hoverMessage = new vscode.MarkdownString(`${copyCommandMd} | ${openWindowCommandMd}\n` + '```clojure\n' + resultString + '\n```'); hoverMessage.isTrusted = true; decoration["hoverMessage"] = status == AnnotationStatus.ERROR ? resultString : hoverMessage; } @@ -169,10 +171,14 @@ function onDidChangeTextDocument(event: vscode.TextDocumentChangeEvent) { } } +function copyHoverTextCommand(args: { [x: string]: string; }) { + vscode.env.clipboard.writeText(args["text"]); +} export default { AnnotationStatus, clearEvaluationDecorations, clearAllEvaluationDecorations, + copyHoverTextCommand, decorateResults, decorateSelection, onDidChangeTextDocument, diff --git a/src/providers/definition.ts b/src/providers/definition.ts index dd5396d02..f08e9d778 100644 --- a/src/providers/definition.ts +++ b/src/providers/definition.ts @@ -50,14 +50,4 @@ export class StackTraceDefinitionProvider implements vscode.DefinitionProvider { return new vscode.Location(entry.uri, pos); } } -} - -export class ResultsDefinitionProvider implements vscode.DefinitionProvider { - state: any; - constructor() { - this.state = state; - } - async provideDefinition(document, position, token) { - return annotations.getResultsLocation(position); - } -} +} \ No newline at end of file