Skip to content

Commit

Permalink
Proof mode does not prevent CTRL+Y on clear
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanR712 committed Apr 4, 2024
1 parent d3f371f commit 289bddc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ProofHistory/ProofHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ export function deleteButtons(stopIndex: number): void {
* Removes the most recent move's button from the proof bar.
*/
export function deleteMostRecentButton(): void {
document.getElementById("Row: " + TreeContext.proof.length)?.remove();
document.getElementById("Row: " + (TreeContext.proof.length + 1))?.remove();
}
23 changes: 17 additions & 6 deletions src/TreeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,22 @@ export class TreeContext {
*/
public static undoProofStep(): void {
if (this.proof.length <= 1) {
this.clearProof();
return;
}

const stepToRemove: ProofModeNode = this.proof[this.proof.length - 1];
const mostRecentStep: ProofModeNode | undefined = this.proof.pop();

if (mostRecentStep === undefined) {
return;
} else if (this.proof.length === 0) {
deleteMostRecentButton();
return;
}

deleteMostRecentButton();

this.proofHistoryRedoStack.push(stepToRemove);
this.proofHistoryRedoStack.push(mostRecentStep);

this.proof.pop();
stepBack(this.proof[this.proof.length - 1]);
redrawProof();

Expand All @@ -174,15 +179,21 @@ export class TreeContext {

const mostRecentStep: ProofModeNode | undefined = this.proofHistoryRedoStack.pop();

if (mostRecentStep === undefined || this.proof[this.proof.length - 1] === undefined) {
if (mostRecentStep === undefined) {
return;
} else if (
this.proofHistoryRedoStack[this.proofHistoryRedoStack.length - 1] === undefined
) {
this.pushToProof(mostRecentStep);
redrawProof();
return;
}

this.recentlyUndoneOrRedoneProofMove = false;

this.pushToProof(mostRecentStep);

stepBack(this.proof[this.proof.length - 1]);
stepBack(mostRecentStep);
redrawProof();
}

Expand Down

0 comments on commit 289bddc

Please sign in to comment.