mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Reduce usage of IRawText (send only what's needed around)
This commit is contained in:
@@ -122,7 +122,7 @@ export abstract class MainThreadDocumentsShape {
|
||||
$tryCreateDocument(options?: { language: string; }): TPromise<any> { throw ni(); }
|
||||
$tryOpenDocument(uri: URI): TPromise<any> { throw ni(); }
|
||||
$registerTextContentProvider(handle: number, scheme: string): void { throw ni(); }
|
||||
$onVirtualDocumentChange(uri: URI, value: editorCommon.IRawText): void { throw ni(); }
|
||||
$onVirtualDocumentChange(uri: URI, value: editorCommon.ITextSource): void { throw ni(); }
|
||||
$unregisterTextContentProvider(handle: number): void { throw ni(); }
|
||||
$trySaveDocument(uri: URI): TPromise<boolean> { throw ni(); }
|
||||
}
|
||||
@@ -282,7 +282,8 @@ export abstract class ExtHostDiagnosticsShape {
|
||||
export interface IModelAddedData {
|
||||
url: URI;
|
||||
versionId: number;
|
||||
value: editorCommon.IRawText;
|
||||
lines: string[];
|
||||
EOL: string;
|
||||
modeId: string;
|
||||
isDirty: boolean;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ export class ExtHostDocuments extends ExtHostDocumentsShape {
|
||||
}
|
||||
|
||||
public $acceptModelAdd(initData: IModelAddedData): void {
|
||||
let data = new ExtHostDocumentData(this._proxy, initData.url, initData.value.lines, initData.value.EOL, initData.modeId, initData.versionId, initData.isDirty);
|
||||
let data = new ExtHostDocumentData(this._proxy, initData.url, initData.lines, initData.EOL, initData.modeId, initData.versionId, initData.isDirty);
|
||||
let key = data.document.uri.toString();
|
||||
if (this._documentData.has(key)) {
|
||||
throw new Error('Document `' + key + '` already exists.');
|
||||
@@ -263,7 +263,7 @@ export class ExtHostDocumentData extends MirrorModel2 {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
equalLines({lines}: editorCommon.IRawText): boolean {
|
||||
equalLines({lines}: editorCommon.ITextSource): boolean {
|
||||
const len = lines.length;
|
||||
if (len !== this._lines.length) {
|
||||
return false;
|
||||
|
||||
@@ -8,7 +8,6 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { EmitterEvent } from 'vs/base/common/eventEmitter';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { RawText } from 'vs/editor/common/model/textModel';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
@@ -103,17 +102,19 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
|
||||
let modelUrl = model.uri;
|
||||
this._modelIsSynced[modelUrl.toString()] = true;
|
||||
this._modelToDisposeMap[modelUrl.toString()] = model.addBulkListener((events) => this._onModelEvents(modelUrl, events));
|
||||
const modelRawText = model.toRawText();
|
||||
this._proxy.$acceptModelAdd({
|
||||
url: model.uri,
|
||||
versionId: model.getVersionId(),
|
||||
value: model.toRawText(),
|
||||
lines: modelRawText.lines,
|
||||
EOL: modelRawText.EOL,
|
||||
modeId: model.getLanguageIdentifier().language,
|
||||
isDirty: this._textFileService.isDirty(modelUrl)
|
||||
});
|
||||
}
|
||||
|
||||
private _onModelModeChanged(event: { model: editorCommon.IModel; oldModeId: string; }): void {
|
||||
let {model, oldModeId} = event;
|
||||
let { model, oldModeId } = event;
|
||||
let modelUrl = model.uri;
|
||||
if (!this._modelIsSynced[modelUrl.toString()]) {
|
||||
return;
|
||||
@@ -240,16 +241,12 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
|
||||
}
|
||||
}
|
||||
|
||||
$onVirtualDocumentChange(uri: URI, value: editorCommon.IRawText): void {
|
||||
$onVirtualDocumentChange(uri: URI, value: editorCommon.ITextSource): void {
|
||||
const model = this._modelService.getModel(uri);
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
// fetch the raw text from the ext host but
|
||||
// reuse the current options
|
||||
const {options} = RawText.fromStringWithModelOptions('', model);
|
||||
const raw = <editorCommon.IRawText>{
|
||||
options,
|
||||
const raw: editorCommon.ITextSource = {
|
||||
lines: value.lines,
|
||||
length: value.length,
|
||||
BOM: value.BOM,
|
||||
|
||||
Reference in New Issue
Block a user