Keep form edits anchored across native autosaves

This commit is contained in:
2026-11-24 15:24:07 +01:00
parent 93a9f04b11
commit 43267824d7
5 changed files with 118 additions and 12 deletions
@@ -122,6 +122,21 @@ class FormDocumentTest {
assertThrows(IllegalArgumentException.class, () -> set("autoCompleteTextField", "width", "20"));
}
@Test
void nativeSaveBetweenPaletteSelectionAndApply() throws Exception {
source = source.replace("<GridPane/>", "<GridPane> \n</GridPane>");
var edit = doc().add("Label", slot("", "children"), 0);
var saved = source.replace("> \n", ">\n");
var changes = FormDocument.forCurrentText(edit, saved);
var result =
new EditBatch(2, "Insert Label", changes)
.applyTo(new DocumentSnapshot(URI.create("file:///test.fxml"), 2, saved, true, false));
assertTrue(new FormDocument(result).items.stream().anyMatch(i -> i.id().equals("label")));
assertThrows(
ConcurrentModificationException.class,
() -> FormDocument.forCurrentText(edit, saved.replace("GridPane", "VBox")));
}
@Test
void implicitToolbarChildrenStayInOneList() throws Exception {
source =