Skip to content

Commit

Permalink
Merge pull request #4 from jakobhellermann/fix-combineinputs-eating-c…
Browse files Browse the repository at this point in the history
…omments

Fix `CombineInputs` eating comments
  • Loading branch information
psyGamer authored Jul 25, 2024
2 parents bf4cc6e + 563b2d9 commit 000776c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Studio/CelesteStudio/Editing/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ public void RemoveLine(int row) {
ChangedText(row, row);
}

/// Removes an inclusive range of lines from min..max
public void RemoveLines(int min, int max) {
PushUndoState();

Expand Down
14 changes: 13 additions & 1 deletion Studio/CelesteStudio/Editing/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,8 +2015,20 @@ private void CombineInputs(bool sameActions) {
int activeRowStart = -1;

for (int row = minRow; row <= maxRow; row++) {
if (!TryParseAndFormatActionLine(row, out var currActionLine))
if (!TryParseAndFormatActionLine(row, out var currActionLine)) {
// "Flush" the previous lines
if (activeActionLine != null) {
Document.RemoveLines(activeRowStart, row - 1);
Document.InsertLine(activeRowStart, activeActionLine.Value.ToString());

maxRow -= row - 1 - activeRowStart;
row = activeRowStart + 1;

activeActionLine = null;
activeRowStart = -1;
}
continue; // Skip non-input lines
}

if (activeActionLine == null) {
activeActionLine = currActionLine;
Expand Down

0 comments on commit 000776c

Please sign in to comment.