Skip to content

Commit

Permalink
Merge pull request #887 from coq-community/manual-goal-view-display
Browse files Browse the repository at this point in the history
feat: Disable the auto display for the proof view
  • Loading branch information
rtetley authored Sep 5, 2024
2 parents a754cb6 + ee0b021 commit 16658a9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
17 changes: 17 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
"title": "Goal and Info view panel",
"type": "object",
"properties": {
"vscoq.goals.auto": {
"scope": "window",
"type": "boolean",
"default": "true",
"description": "Should the goal view automatically display when navigating a coq document."
},
"vscoq.goals.display": {
"scope": "window",
"type": "string",
Expand Down Expand Up @@ -338,6 +344,12 @@
"category": "Coq",
"icon": "$(arrow-up)"
},
{
"command": "extension.coq.displayProofView",
"title": "Display Proof View",
"category": "Coq",
"icon": "$(open-preview)"
},
{
"command": "extension.coq.documentState",
"title": "Troubleshooting: Get current document state",
Expand Down Expand Up @@ -391,6 +403,11 @@
"command": "extension.coq.reset",
"group": "navigation@5"
},
{
"when": "resourceLangId == coq && !config.vscoq.goals.auto",
"command": "extension.coq.displayProofView",
"group": "navigation@0"
},
{
"when": "resourceLangId == coq",
"submenu": "vscoq.menu",
Expand Down
9 changes: 6 additions & 3 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {workspace, window, commands, languages, ExtensionContext, env,
TextEditorSelectionChangeEvent,
TextEditorSelectionChangeKind,
TextEditor,
ViewColumn,
TextEditorRevealType,
Expand All @@ -10,7 +9,6 @@ import {workspace, window, commands, languages, ExtensionContext, env,
extensions,
StatusBarAlignment,
MarkdownString,
TextEdit,
WorkspaceEdit
} from 'vscode';

Expand Down Expand Up @@ -251,6 +249,10 @@ export function activate(context: ExtensionContext) {
registerVscoqTextCommand('showManual', () => {
commands.executeCommand('simpleBrowser.show', 'https://coq.inria.fr/doc/master/refman/index.html');
});
registerVscoqTextCommand('displayProofView', () => {
const editor = window.activeTextEditor ? window.activeTextEditor : window.visibleTextEditors[0];
GoalPanel.displayProofView(context.extensionUri, editor);
});

client.onNotification("vscoq/updateHighlights", (notification) => {

Expand Down Expand Up @@ -284,7 +286,8 @@ export function activate(context: ExtensionContext) {

client.onNotification("vscoq/proofView", (proofView: ProofViewNotification) => {
const editor = window.activeTextEditor ? window.activeTextEditor : window.visibleTextEditors[0];
GoalPanel.proofViewNotification(context.extensionUri, editor, proofView);
const autoDisplay = workspace.getConfiguration('vscoq.goals').auto;
GoalPanel.proofViewNotification(context.extensionUri, editor, proofView, autoDisplay);
});

client.onNotification("vscoq/blockOnError", (notification: ErrorAlertNotification) => {
Expand Down
24 changes: 19 additions & 5 deletions client/src/panels/GoalPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Client from "../client";
export default class GoalPanel {

public static currentPanel: GoalPanel | undefined;
public static currentPv: ProofViewNotification | undefined;
private readonly _panel: WebviewPanel;
private _disposables: Disposable[] = [];

Expand Down Expand Up @@ -151,15 +152,22 @@ export default class GoalPanel {
// Create the goal panel if it doesn't exit and then
// handle a proofview notification
// /////////////////////////////////////////////////////////////////////////////
public static proofViewNotification(extensionUri: Uri, editor: TextEditor, pv: ProofViewNotification) {
public static proofViewNotification(extensionUri: Uri, editor: TextEditor, pv: ProofViewNotification, autoDisplay: boolean) {

Client.writeToVscoq2Channel("[GoalPanel] Received proofview notification");

if(!GoalPanel.currentPanel) {
GoalPanel.render(editor, extensionUri, (goalPanel) => {
Client.writeToVscoq2Channel("[GoalPanel] Created new goal panel");
goalPanel._handleProofViewResponseOrNotification(pv);
});
//If autoDisplay is set then render the proofview immediately
if(autoDisplay) {
GoalPanel.render(editor, extensionUri, (goalPanel) => {
Client.writeToVscoq2Channel("[GoalPanel] Created new goal panel");
goalPanel._handleProofViewResponseOrNotification(pv);
});
}
//Otherwise record the current proofview notification to render on user prompt
else {
GoalPanel.currentPv = pv;
}
}
else {
Client.writeToVscoq2Channel("[GoalPanel] Rendered in current panel");
Expand All @@ -168,6 +176,12 @@ export default class GoalPanel {

}

public static displayProofView(extensionUri: Uri, editor: TextEditor) {
if(GoalPanel.currentPv) {
GoalPanel.proofViewNotification(extensionUri, editor, GoalPanel.currentPv, true);
}
}

private _reset() {
this._panel.webview.postMessage({ "command": "reset"});
};
Expand Down
Binary file added gif/auto-display-disable.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 16658a9

Please sign in to comment.