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

don't raise events in FixInvalidInput to prevent caret movement in undo #81

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 13 additions & 1 deletion Studio/CelesteStudio/Editing/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,15 @@ public void PushChange(int minRow, int maxRow) {
public void Dispose() {
document.updateStack.Pop();

if (!raiseEvents || currMinRow == -1 || currMaxRow == -1) {
if (!raiseEvents) {
return;
}
if (currMinRow == -1 || currMaxRow == -1) {
if (raiseEvents) {
// Revert the undo-stack entry to prevent empty entries
document.undoStack.Undo();
}

return;
}

Expand Down Expand Up @@ -568,6 +576,10 @@ public void InsertLines(int row, string[] newLines) {
}

public void ReplaceLine(int row, string text) {
if (Lines[row] == text) {
return;
}

var newLines = text.SplitDocumentLines();
ReplaceLines(row, newLines);
}
Expand Down
2 changes: 1 addition & 1 deletion Studio/CelesteStudio/Editing/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public void FixInvalidInputs() {
}
}
private void FixInvalidInput(int row) {
using var __ = Document.Update();
using var __ = Document.Update(raiseEvents: false);

// Frameless action lines are only intended for editing and shouldn't be part of the final TAS
if (ActionLine.TryParse(Document.Lines[row], out var actionLine)) {
Expand Down
Loading