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

Add option to disable super-slow "Proof View Diff" #321

Merged
merged 3 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
"default": "first-interaction",
"description": "Create the proof view when a Coq script is opened, the user first interacts with coqtop, or else let the user do it manually."
},
"coq.proofViewDiff": {
"type": "boolean",
"default": "true",
"markdownDescription": "Enable/disable VsCoq's Proof View Diff. Only has acceptable performance on small goals."
},
"coq.proofViewDiff.addedTextIsItalic": {
"type": "boolean",
"default": false,
Expand Down
1 change: 1 addition & 0 deletions server/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface CoqSettings {
/** After each command, check sentence-states for inconsistencies */
checkSentenceStateConsistency?: boolean,
}
proofViewDiff: boolean
}

export interface FailValue {
Expand Down
9 changes: 6 additions & 3 deletions server/src/stm/STM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ export class CoqStateMachine {
endCommand();
}
}
private get proofViewDiff(): boolean {
return server.project.settings.coq.proofViewDiff
Blaisorblade marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Return the cached goal for the given position
Expand All @@ -429,7 +432,7 @@ export class CoqStateMachine {
try {
const state = (direction==="subsequent" ? this.getStateAt(pos) : null) || this.getPrecedingStateAt(pos);
if(state && state.hasGoal())
return Object.assign({type: 'proof-view'} as {type: 'proof-view'}, state.getGoal(this.goalsCache));
return Object.assign({type: 'proof-view'} as {type: 'proof-view'}, state.getGoal(this.goalsCache, this.proofViewDiff));
else
return {type: "no-proof"}
} catch(error) {
Expand Down Expand Up @@ -857,7 +860,7 @@ private routeId = 1;
focus: this.getFocusedPosition()
});
this.focusedSentence.setGoal(pv);
return {type: 'proof-view', ...this.focusedSentence.getGoal(this.goalsCache)};
return {type: 'proof-view', ...this.focusedSentence.getGoal(this.goalsCache, this.proofViewDiff)};
default:
this.console.warn("Goal returned an unexpected value: " + util.inspect(goals,false,undefined));
}
Expand Down Expand Up @@ -1207,4 +1210,4 @@ function createDebuggingSentence(sent: State) : DSentence {
// public inspect() {
// return {cmd: this.cmd, range: this.range}
// }
// }
// }
14 changes: 7 additions & 7 deletions server/src/stm/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class State {
private diagnostics: CoqDiagnosticInternal[] = [];
// set to true when a document change has invalidated the meaning of the associated sentence; this state needs to be cancelled
private markedInvalidated = false;
private goal : ProofViewReference | null = null;
private goal : ProofViewReference | null = null;

private constructor
( private commandText: string
Expand Down Expand Up @@ -145,7 +145,7 @@ export class State {
}

public updateWorkerStatus(workerId: string, status: string) {

}

/** Handle sentence-status updates as they come from coqtop */
Expand Down Expand Up @@ -191,16 +191,16 @@ export class State {
this.goal = goal;
}

public getGoal(goalsCache: GoalsCache) : ProofView|null {
public getGoal(goalsCache: GoalsCache, proofViewDiff : boolean) : ProofView|null {
if(!this.goal)
return null;
const newGoals = {...goalsCache.getProofView(this.goal), focus: this.textRange.end};
if(this.prev && this.prev.goal) {
if(this.prev && this.prev.goal && proofViewDiff) {
const oldGoals = goalsCache.getProofView(this.prev.goal);
return diff.diffProofView(oldGoals, newGoals);
}
return newGoals;
}
}

private translateDiagnostic(d : CoqDiagnosticInternal, delta: textUtil.RangeDelta) : void {
if (d.range) {
Expand Down Expand Up @@ -326,7 +326,7 @@ export class State {
return textUtil.positionIsAfterOrEqual(this.textRange.start, position) ||
textUtil.positionIsAfter(this.textRange.end, position);
}

/** @returns `true` if this sentence contains `position`. */
public contains(position: Position) : boolean {
return textUtil.positionIsBeforeOrEqual(this.textRange.start, position) &&
Expand Down Expand Up @@ -359,4 +359,4 @@ export class State {
return this.diagnostics.map(function(d) { return Object.assign(d, {sentence: range})});
}

}
}