Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ public void closeSubPanels() {
@ApiStatus.Internal
@Override
public void closePanelInternal() {
getSyncManager().getModularSyncManager().close(this.panelName);
this.open = false;
// Sync infrastructure may already be torn down if the screen was disposed
// (e.g. deferred PanelManager.dispose() running after ModularNetwork.closeAll())
if (!isValid()) return;
getSyncManager().getModularSyncManager().close(this.panelName);
if (getSyncManager().isClient()) {
syncToServer(SYNC_CLOSE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,10 @@ private Point insert(List<String> text, List<String> insertion) {
text.addAll(insertion);
return new Point(text.get(text.size() - 1).length(), text.size() - 1);
}
String lineStart = text.get(this.cursor.y).substring(0, this.cursor.x);
String lineEnd = text.get(this.cursor.y).substring(this.cursor.x);
String line = text.get(this.cursor.y);
int cursorX = Math.min(this.cursor.x, line.length());
String lineStart = line.substring(0, cursorX);
String lineEnd = line.substring(cursorX);
if (insertion.size() == 1 && text.size() == 1 && !test(lineStart + insertion.get(0) + lineEnd)) {
return null;
}
Expand All @@ -338,7 +340,7 @@ private Point insert(List<String> text, List<String> insertion) {
return null;
}
text.set(this.cursor.y, text.get(this.cursor.y) + lineEnd);
return new Point(this.cursor.x + insertion.get(0).length(), this.cursor.y);
return new Point(cursorX + insertion.get(0).length(), this.cursor.y);
} else {
text.add(this.cursor.y + 1, insertion.get(insertion.size() - 1) + lineEnd);
x = insertion.get(insertion.size() - 1).length();
Expand Down