# How to preserve the state of a VirtualFile that does not physically exists in the FileSystem

**URL:** https://platform.jetbrains.com/t/how-to-preserve-the-state-of-a-virtualfile-that-does-not-physically-exists-in-the-filesystem/2792
**Category:** IntelliJ Platform
**Created:** [September 23, 2025, 12:53pm UTC](https://platform.jetbrains.com/t/how-to-preserve-the-state-of-a-virtualfile-that-does-not-physically-exists-in-the-filesystem/2792 "2025-09-23T12:53:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gilby\_Sunil](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gilby\_Sunil](https://platform.jetbrains.com/u/Gilby_Sunil)
#### Post date: [September 23, 2025, 12:53pm UTC](https://platform.jetbrains.com/t/how-to-preserve-the-state-of-a-virtualfile-that-does-not-physically-exists-in-the-filesystem/2792/1 "2025-09-23T12:53:14Z")

</div>

I’m working on a JetBrains plugin where I open a custom editor tab that renders a web page using JCEF. This is done by attaching a `VirtualFile` to the editor, which then loads the JCEF browser component inside the editor tab. When the editor is moved (for example, to another split or to a different tab group), I need to transfer the state from old editor to the new one. An editor state is preserved in IntelliJ only if either of the following conditions are met (Please see: [intellij-community/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.kt at 6e43b3144cc2a4b244c0bfcc5e7bdfa3c9a131e2 · JetBrains/intellij-community · GitHub](https://github.com/JetBrains/intellij-community/blob/6e43b3144cc2a4b244c0bfcc5e7bdfa3c9a131e2/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.kt#L94)):

1. The `VirtualFile` used to render the WebView is an instance of the `OptionallyIncluded` interface, or

2. The `VirtualFile` physically exists in the file system.

The problem I am facing is that, IntelliJ marked `OptionallyIncluded` interface as internal. So, I cannot use that. And since I am loading a JCEF component inside the editor by attaching it to a `VirtualFile`, it does not physically exists in the FileSystem.

Is there any work around for this?

---

<div class="post-metadata">

### Author: ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)
#### Post date: [September 23, 2025, 5:38pm UTC](https://platform.jetbrains.com/t/how-to-preserve-the-state-of-a-virtualfile-that-does-not-physically-exists-in-the-filesystem/2792/2 "2025-09-23T17:38:22Z")

</div>

Is it related to this topic? What task are you trying to solve?

> [@Preserving and Restoring State in JCEF-based Editor Tabs when Editor is Moved Around](https://platform.jetbrains.com/t/preserving-and-restoring-state-in-jcef-based-editor-tabs-when-editor-is-moved-around/2757):
>
> I’m working on a JetBrains plugin where I open a custom editor tab that renders a web page using JCEF. This is done by attaching a VirtualFile to the editor, which then loads the JCEF browser component inside the editor tab. The problem I’m encountering is related to editor tab movement. When the editor is moved (for example, to another split or to a different tab group), it appears that the original editor is disposed and a new instance of the editor is created. As a result, the state associat…

---

<div class="post-metadata">

### Author: ![Gilby\_Sunil](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gilby\_Sunil](https://platform.jetbrains.com/u/Gilby_Sunil)
#### Post date: [September 24, 2025, 7:46am UTC](https://platform.jetbrains.com/t/how-to-preserve-the-state-of-a-virtualfile-that-does-not-physically-exists-in-the-filesystem/2792/3 "2025-09-24T07:46:21Z")

</div>

Yes it is. After debugging the IntelliJ IDE, I found that the above stated issue was the root cause. Therefore, I would like to know if there is a way to preserve the state of a JCEF component that is rendered inside a VirtualFile since it does not physically exists in the file system.
