Connect minimal hosts to snapshots, target workers and shared Kit editing
This commit is contained in:
+42
-2
@@ -9,7 +9,8 @@ public final class IntellijDocumentsTest extends BasePlatformTestCase {
|
||||
public void testNativeDocumentTransactionUndoAndIndependentHandles() throws Exception {
|
||||
Path file = Files.createTempFile("designer-document-", ".fxml");
|
||||
Files.writeString(file, "abcdef");
|
||||
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(getTestRootDisposable(), file.toRealPath().toString());
|
||||
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
|
||||
getTestRootDisposable(), file.toRealPath().toString());
|
||||
try (var docs = new IntellijDocuments(getProject())) {
|
||||
var a = docs.open(file.toUri()).toCompletableFuture().get();
|
||||
var b = docs.open(file.toUri()).toCompletableFuture().get();
|
||||
@@ -48,7 +49,8 @@ public final class IntellijDocumentsTest extends BasePlatformTestCase {
|
||||
public void testExternalChangesDoNotLoseDraft() throws Exception {
|
||||
Path file = Files.createTempFile("designer-conflict-", ".fxml");
|
||||
Files.writeString(file, "old");
|
||||
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(getTestRootDisposable(), file.toRealPath().toString());
|
||||
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
|
||||
getTestRootDisposable(), file.toRealPath().toString());
|
||||
try (var docs = new IntellijDocuments(getProject())) {
|
||||
var d = docs.open(file.toUri()).toCompletableFuture().get();
|
||||
var changed =
|
||||
@@ -69,4 +71,42 @@ public final class IntellijDocumentsTest extends BasePlatformTestCase {
|
||||
Files.deleteIfExists(file);
|
||||
}
|
||||
}
|
||||
|
||||
public void testKeepsNativeDocumentOpenedThroughAlias() throws Exception {
|
||||
Path directory = Files.createTempDirectory("designer-alias-");
|
||||
Path real = directory.resolve("real");
|
||||
Files.createDirectory(real);
|
||||
Path alias = directory.resolve("alias");
|
||||
Files.createSymbolicLink(alias, real);
|
||||
Path file = real.resolve("View.fxml");
|
||||
Files.writeString(file, "before");
|
||||
com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess.allowRootAccess(
|
||||
getTestRootDisposable(), directory.toRealPath().toString(), directory.toString());
|
||||
var virtual =
|
||||
com.intellij.openapi.vfs.LocalFileSystem.getInstance()
|
||||
.refreshAndFindFileByNioFile(alias.resolve("View.fxml"));
|
||||
var nativeDocument =
|
||||
com.intellij.openapi.fileEditor.FileDocumentManager.getInstance().getDocument(virtual);
|
||||
try (var docs = new IntellijDocuments(getProject());
|
||||
var handle = docs.open(alias.resolve("View.fxml").toUri()).toCompletableFuture().get()) {
|
||||
var before = handle.snapshot().toCompletableFuture().get();
|
||||
var after =
|
||||
handle
|
||||
.apply(
|
||||
new EditBatch(
|
||||
before.revision(),
|
||||
"Alias edit",
|
||||
List.of(new EditBatch.Replacement(0, before.text().length(), "after"))))
|
||||
.toCompletableFuture()
|
||||
.get();
|
||||
assertEquals("after", nativeDocument.getText());
|
||||
assertEquals(file.toRealPath().toUri(), after.document());
|
||||
handle.save(after.revision()).toCompletableFuture().get();
|
||||
} finally {
|
||||
Files.deleteIfExists(alias);
|
||||
Files.deleteIfExists(file);
|
||||
Files.deleteIfExists(real);
|
||||
Files.deleteIfExists(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user