mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
checks models when file events happen
This commit is contained in:
@@ -494,13 +494,19 @@ export class MainThreadDocuments {
|
||||
modelService.onModelModeChanged(this._onModelModeChanged, this, this._toDispose);
|
||||
|
||||
this._toDispose.push(eventService.addListener2(FileEventType.FILE_SAVED, (e: LocalFileChangeEvent) => {
|
||||
this._proxy._acceptModelSaved(e.getAfter().resource.toString());
|
||||
if (this._shouldHandleFileEvent(e)) {
|
||||
this._proxy._acceptModelSaved(e.getAfter().resource.toString());
|
||||
}
|
||||
}));
|
||||
this._toDispose.push(eventService.addListener2(FileEventType.FILE_REVERTED, (e: LocalFileChangeEvent) => {
|
||||
this._proxy._acceptModelReverted(e.getAfter().resource.toString());
|
||||
if (this._shouldHandleFileEvent(e)) {
|
||||
this._proxy._acceptModelReverted(e.getAfter().resource.toString());
|
||||
}
|
||||
}));
|
||||
this._toDispose.push(eventService.addListener2(FileEventType.FILE_DIRTY, (e: LocalFileChangeEvent) => {
|
||||
this._proxy._acceptModelDirty(e.getAfter().resource.toString());
|
||||
if (this._shouldHandleFileEvent(e)) {
|
||||
this._proxy._acceptModelDirty(e.getAfter().resource.toString());
|
||||
}
|
||||
}));
|
||||
|
||||
const handle = setInterval(() => this._runDocumentCleanup(), 30 * 1000);
|
||||
@@ -519,6 +525,12 @@ export class MainThreadDocuments {
|
||||
this._toDispose = disposeAll(this._toDispose);
|
||||
}
|
||||
|
||||
private _shouldHandleFileEvent(e: LocalFileChangeEvent): boolean {
|
||||
const after = e.getAfter();
|
||||
const model = this._modelService.getModel(after.resource);
|
||||
return !model && !model.isTooLargeForHavingARichMode();
|
||||
}
|
||||
|
||||
private _onModelAdded(model: EditorCommon.IModel): void {
|
||||
// Same filter as in mainThreadEditors
|
||||
if (model.isTooLargeForHavingARichMode()) {
|
||||
|
||||
Reference in New Issue
Block a user