Skip to content

Commit 16658a9

Browse files
authored
Merge pull request #887 from coq-community/manual-goal-view-display
feat: Disable the auto display for the proof view
2 parents a754cb6 + ee0b021 commit 16658a9

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

client/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@
121121
"title": "Goal and Info view panel",
122122
"type": "object",
123123
"properties": {
124+
"vscoq.goals.auto": {
125+
"scope": "window",
126+
"type": "boolean",
127+
"default": "true",
128+
"description": "Should the goal view automatically display when navigating a coq document."
129+
},
124130
"vscoq.goals.display": {
125131
"scope": "window",
126132
"type": "string",
@@ -338,6 +344,12 @@
338344
"category": "Coq",
339345
"icon": "$(arrow-up)"
340346
},
347+
{
348+
"command": "extension.coq.displayProofView",
349+
"title": "Display Proof View",
350+
"category": "Coq",
351+
"icon": "$(open-preview)"
352+
},
341353
{
342354
"command": "extension.coq.documentState",
343355
"title": "Troubleshooting: Get current document state",
@@ -391,6 +403,11 @@
391403
"command": "extension.coq.reset",
392404
"group": "navigation@5"
393405
},
406+
{
407+
"when": "resourceLangId == coq && !config.vscoq.goals.auto",
408+
"command": "extension.coq.displayProofView",
409+
"group": "navigation@0"
410+
},
394411
{
395412
"when": "resourceLangId == coq",
396413
"submenu": "vscoq.menu",

client/src/extension.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {workspace, window, commands, languages, ExtensionContext, env,
22
TextEditorSelectionChangeEvent,
3-
TextEditorSelectionChangeKind,
43
TextEditor,
54
ViewColumn,
65
TextEditorRevealType,
@@ -10,7 +9,6 @@ import {workspace, window, commands, languages, ExtensionContext, env,
109
extensions,
1110
StatusBarAlignment,
1211
MarkdownString,
13-
TextEdit,
1412
WorkspaceEdit
1513
} from 'vscode';
1614

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

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

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

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

290293
client.onNotification("vscoq/blockOnError", (notification: ErrorAlertNotification) => {

client/src/panels/GoalPanel.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Client from "../client";
2121
export default class GoalPanel {
2222

2323
public static currentPanel: GoalPanel | undefined;
24+
public static currentPv: ProofViewNotification | undefined;
2425
private readonly _panel: WebviewPanel;
2526
private _disposables: Disposable[] = [];
2627

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

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

158159
if(!GoalPanel.currentPanel) {
159-
GoalPanel.render(editor, extensionUri, (goalPanel) => {
160-
Client.writeToVscoq2Channel("[GoalPanel] Created new goal panel");
161-
goalPanel._handleProofViewResponseOrNotification(pv);
162-
});
160+
//If autoDisplay is set then render the proofview immediately
161+
if(autoDisplay) {
162+
GoalPanel.render(editor, extensionUri, (goalPanel) => {
163+
Client.writeToVscoq2Channel("[GoalPanel] Created new goal panel");
164+
goalPanel._handleProofViewResponseOrNotification(pv);
165+
});
166+
}
167+
//Otherwise record the current proofview notification to render on user prompt
168+
else {
169+
GoalPanel.currentPv = pv;
170+
}
163171
}
164172
else {
165173
Client.writeToVscoq2Channel("[GoalPanel] Rendered in current panel");
@@ -168,6 +176,12 @@ export default class GoalPanel {
168176

169177
}
170178

179+
public static displayProofView(extensionUri: Uri, editor: TextEditor) {
180+
if(GoalPanel.currentPv) {
181+
GoalPanel.proofViewNotification(extensionUri, editor, GoalPanel.currentPv, true);
182+
}
183+
}
184+
171185
private _reset() {
172186
this._panel.webview.postMessage({ "command": "reset"});
173187
};

gif/auto-display-disable.gif

1.59 MB
Loading

0 commit comments

Comments
 (0)