Preserve FXML source ranges and extend shared Component projection
This commit is contained in:
+21
-1
@@ -149,6 +149,21 @@ public final class IntellijDocuments implements HostServices.Documents, AutoClos
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshClean(State s) throws java.io.IOException {
|
||||
var manager = FileDocumentManager.getInstance();
|
||||
if (manager.isDocumentUnsaved(s.document)) return;
|
||||
String disk = Files.readString(Path.of(s.file.getPath()));
|
||||
if (disk.equals(s.document.getText())) {
|
||||
s.disk = disk; // Native autosave already persisted this revision; do not reload it.
|
||||
return;
|
||||
}
|
||||
if (!disk.equals(s.disk)) {
|
||||
s.file.refresh(false, false);
|
||||
manager.reloadFromDisk(s.document);
|
||||
s.disk = disk;
|
||||
}
|
||||
}
|
||||
|
||||
private DocumentSnapshot snapshot(State s) {
|
||||
return new DocumentSnapshot(
|
||||
canonicalUri(s.file),
|
||||
@@ -176,12 +191,17 @@ public final class IntellijDocuments implements HostServices.Documents, AutoClos
|
||||
}
|
||||
|
||||
public CompletionStage<DocumentSnapshot> snapshot() {
|
||||
return run(() -> IntellijDocuments.this.snapshot(s));
|
||||
return run(
|
||||
() -> {
|
||||
refreshClean(s);
|
||||
return IntellijDocuments.this.snapshot(s);
|
||||
});
|
||||
}
|
||||
|
||||
public CompletionStage<DocumentSnapshot> apply(EditBatch edits) {
|
||||
return run(
|
||||
() -> {
|
||||
refreshClean(s);
|
||||
edits.applyTo(IntellijDocuments.this.snapshot(s));
|
||||
var ranges = new ArrayList<>(edits.replacements());
|
||||
ranges.sort(Comparator.comparingInt(EditBatch.Replacement::start));
|
||||
|
||||
Reference in New Issue
Block a user