-
Notifications
You must be signed in to change notification settings - Fork 29.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use notebook serializer for IW model #171283
use notebook serializer for IW model #171283
Conversation
4fd748b
to
dc66610
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the approach looks good to me but also run the FS changes by Ben to make sure this won't cause issues with editor state / backups
src/vs/workbench/contrib/interactive/browser/dummyFileSystemProvider.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me in overall. The only thing we want to double check how IW restore works with different settings (auto save on/off) as we are faking FS/dirty-state.
src/vs/workbench/contrib/interactive/browser/dummyFileSystemProvider.ts
Outdated
Show resolved
Hide resolved
dc66610
to
3f8f39d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure why the no-op filesystem provider is needed to begin with, but instead of implementing this yourself, why not use the InMemoryFileSystemProvider
we already have:
export class InMemoryFileSystemProvider extends Disposable implements IFileSystemProviderWithFileReadWriteCapability { |
src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/interactive/browser/InteractiveWindowFileSystem.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/interactive/browser/InteractiveWindowFileSystem.ts
Outdated
Show resolved
Hide resolved
There are write operations that occur for auto-save, so it just feels like we would be unnecessarily duplicating the memory usage since it's already stored in the back-up provider. On the other hand, that provider would likely be a better fit for the intended model, so I'm fine with using it if that extra memory usage isn't a concern. |
9738ba8
to
c18791b
Compare
After discussing with @bpasero, dropping all writes is preferrable to storing the data we don't actually need in an in-memory file provider |
|
||
public async rename(_from: URI, _to: URI, _opts: IFileOverwriteOptions): Promise<void> { } | ||
|
||
public async close?(_fd: number): Promise<void> { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a bit weird to have the ?
even though you implement the method.
|
||
public constructor(private disposableFactory: () => IDisposable = () => Disposable.None) { } | ||
|
||
public async readFile(_resource: URI): Promise<Uint8Array> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fyi you can remove the public
keyword, this will make the method public
by default.
import { URI } from 'vs/base/common/uri'; | ||
import { FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileSystemProvider, IStat, IWatchOptions } from 'vs/platform/files/common/files'; | ||
|
||
export class InteractiveWindowFileSystem implements IFileSystemProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can reduce the complexity of this class by extending the InMemoryFileSystemProvider
and simply overriding the methods that write to the memory by skipping the write. This will make this a very slim class in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments how to further simplify this. I still do not understand why we need this, but I trust the judgment, since additional discussions seem to have happened.
274f694
to
801c09f
Compare
Use a file Provider for the interactive window so that the notebook serializer is used for the notebook model.
The IW file provider will drop any write operations and return an empty buffer for any read.
This way we will rely only on the backup provider to store the file data similar to an untitled file, but it won't request to save the file on close or appear dirty.