textModel: add isForSimpleWidget property so these model are not synchronized

This commit is contained in:
isidor
2018-03-20 16:24:59 +01:00
parent 38bb950e17
commit f470ce19e7
19 changed files with 204 additions and 101 deletions

View File

@@ -6,7 +6,7 @@
import URI, { UriComponents } from 'vs/base/common/uri';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModelService, shouldSynchronizeModel } from 'vs/editor/common/services/modelService';
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
import { TextFileModelChangeEvent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { TPromise } from 'vs/base/common/winjs.base';
@@ -132,12 +132,12 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
private _shouldHandleFileEvent(e: TextFileModelChangeEvent): boolean {
const model = this._modelService.getModel(e.resource);
return model && !model.isTooLargeForHavingARichMode();
return model && shouldSynchronizeModel(model);
}
private _onModelAdded(model: ITextModel): void {
// Same filter as in mainThreadEditorsTracker
if (model.isTooLargeForHavingARichMode()) {
if (!shouldSynchronizeModel(model)) {
// don't synchronize too large models
return null;
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModelService, shouldSynchronizeModel } from 'vs/editor/common/services/modelService';
import { ITextModel } from 'vs/editor/common/model';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
@@ -192,7 +192,7 @@ class MainThreadDocumentAndEditorStateComputer {
}
private _updateStateOnModelAdd(model: ITextModel): void {
if (model.isTooLargeForHavingARichMode()) {
if (!shouldSynchronizeModel(model)) {
// ignore
return;
}
@@ -222,7 +222,7 @@ class MainThreadDocumentAndEditorStateComputer {
// models: ignore too large models
const models = new Set<ITextModel>();
for (const model of this._modelService.getModels()) {
if (!model.isTooLargeForHavingARichMode()) {
if (shouldSynchronizeModel(model)) {
models.add(model);
}
}
@@ -233,8 +233,11 @@ class MainThreadDocumentAndEditorStateComputer {
let activeEditor: string = null;
for (const editor of this._codeEditorService.listCodeEditors()) {
if (editor.isSimpleWidget) {
continue;
}
const model = editor.getModel();
if (model && !model.isTooLargeForHavingARichMode()
if (model && shouldSynchronizeModel(model)
&& !model.isDisposed() // model disposed
&& Boolean(this._modelService.getModel(model.uri)) // model disposing, the flag didn't flip yet but the model service already removed it
) {

View File

@@ -322,7 +322,7 @@ export class MainThreadTextEditor {
if (newConfiguration.tabSize === 'auto' || newConfiguration.insertSpaces === 'auto') {
// one of the options was set to 'auto' => detect indentation
let creationOpts = this._modelService.getCreationOptions(this._model.getLanguageIdentifier().language, this._model.uri);
let creationOpts = this._modelService.getCreationOptions(this._model.getLanguageIdentifier().language, this._model.uri, this._model.isForSimpleWidget);
let insertSpaces = creationOpts.insertSpaces;
let tabSize = creationOpts.tabSize;

View File

@@ -28,6 +28,7 @@ import { IProgressService2, ProgressLocation } from 'vs/platform/progress/common
import { localize } from 'vs/nls';
import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
import { shouldSynchronizeModel } from 'vs/editor/common/services/modelService';
export interface ISaveParticipantParticipant extends ISaveParticipant {
// progressMessage: string;
@@ -261,7 +262,7 @@ class ExtHostSaveParticipant implements ISaveParticipantParticipant {
participate(editorModel: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
if (editorModel.textEditorModel.isTooLargeForHavingARichMode()) {
if (!shouldSynchronizeModel(editorModel.textEditorModel)) {
// the model never made it to the extension
// host meaning we cannot participate in its save
return undefined;

View File

@@ -244,7 +244,7 @@ export function createApiFactory(
return extHostLanguages.getLanguages();
},
match(selector: vscode.DocumentSelector, document: vscode.TextDocument): number {
return score(toLanguageSelector(selector), document.uri, document.languageId);
return score(toLanguageSelector(selector), document.uri, document.languageId, true);
},
registerCodeActionsProvider(selector: vscode.DocumentSelector, provider: vscode.CodeActionProvider): vscode.Disposable {
return extHostLanguageFeatures.registerCodeActionProvider(selector, provider);