mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-28 08:04:00 +01:00
Remove usage of CustomMarshaller for MainThreadEditors (#40169)
This commit is contained in:
@@ -372,10 +372,12 @@ class DecorationCSSRules {
|
||||
|
||||
if (typeof opts !== 'undefined') {
|
||||
this.collectBorderSettingsCSSText(opts, cssTextArr);
|
||||
if (typeof opts.contentIconPath === 'string') {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.contentIconPath, URI.file(opts.contentIconPath).toString().replace(/'/g, '%27')));
|
||||
} else if (opts.contentIconPath instanceof URI) {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.contentIconPath, opts.contentIconPath.toString(true).replace(/'/g, '%27')));
|
||||
if (typeof opts.contentIconPath !== 'undefined') {
|
||||
if (typeof opts.contentIconPath === 'string') {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.contentIconPath, URI.file(opts.contentIconPath).toString().replace(/'/g, '%27')));
|
||||
} else {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.contentIconPath, URI.revive(opts.contentIconPath).toString(true).replace(/'/g, '%27')));
|
||||
}
|
||||
}
|
||||
if (typeof opts.contentText === 'string') {
|
||||
const truncated = opts.contentText.match(/^.*$/m)[0]; // only take first line
|
||||
@@ -405,7 +407,7 @@ class DecorationCSSRules {
|
||||
if (typeof opts.gutterIconPath === 'string') {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, URI.file(opts.gutterIconPath).toString()));
|
||||
} else {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, opts.gutterIconPath.toString(true).replace(/'/g, '%27')));
|
||||
cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, URI.revive(opts.gutterIconPath).toString(true).replace(/'/g, '%27')));
|
||||
}
|
||||
if (typeof opts.gutterIconSize !== 'undefined') {
|
||||
cssTextArr.push(strings.format(_CSS_MAP.gutterIconSize, opts.gutterIconSize));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import URI, { UriComponents } from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { LanguageId, LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
@@ -1565,7 +1565,7 @@ export interface IThemeDecorationRenderOptions {
|
||||
color?: string | ThemeColor;
|
||||
letterSpacing?: string;
|
||||
|
||||
gutterIconPath?: string | URI;
|
||||
gutterIconPath?: string | UriComponents;
|
||||
gutterIconSize?: string;
|
||||
|
||||
overviewRulerColor?: string | ThemeColor;
|
||||
@@ -1579,7 +1579,7 @@ export interface IThemeDecorationRenderOptions {
|
||||
*/
|
||||
export interface IContentDecorationRenderOptions {
|
||||
contentText?: string;
|
||||
contentIconPath?: string | URI;
|
||||
contentIconPath?: string | UriComponents;
|
||||
|
||||
border?: string;
|
||||
borderColor?: string | ThemeColor;
|
||||
|
||||
@@ -176,11 +176,11 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
$trySetDecorationsFast(id: string, key: string, ranges: string): TPromise<any> {
|
||||
$trySetDecorationsFast(id: string, key: string, ranges: number[]): TPromise<any> {
|
||||
if (!this._documentsAndEditors.getEditor(id)) {
|
||||
return TPromise.wrapError(disposed(`TextEditor(${id})`));
|
||||
}
|
||||
this._documentsAndEditors.getEditor(id).setDecorationsFast(key, /*TODO: marshaller is too slow*/JSON.parse(ranges));
|
||||
this._documentsAndEditors.getEditor(id).setDecorationsFast(key, ranges);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,8 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
for (let i = 0, len = workspaceResourceEdits.length; i < len; i++) {
|
||||
const workspaceResourceEdit = workspaceResourceEdits[i];
|
||||
if (workspaceResourceEdit.modelVersionId) {
|
||||
let model = this._modelService.getModel(workspaceResourceEdit.resource);
|
||||
const uri = URI.revive(workspaceResourceEdit.resource);
|
||||
let model = this._modelService.getModel(uri);
|
||||
if (model && model.getVersionId() !== workspaceResourceEdit.modelVersionId) {
|
||||
// model changed in the meantime
|
||||
return TPromise.as(false);
|
||||
@@ -225,7 +226,7 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
let resourceEdits: IResourceEdit[] = [];
|
||||
for (let i = 0, len = workspaceResourceEdits.length; i < len; i++) {
|
||||
const workspaceResourceEdit = workspaceResourceEdits[i];
|
||||
const uri = workspaceResourceEdit.resource;
|
||||
const uri = URI.revive(workspaceResourceEdit.resource);
|
||||
const edits = workspaceResourceEdit.edits;
|
||||
|
||||
for (let j = 0, lenJ = edits.length; j < lenJ; j++) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import URI, { UriComponents } from 'vs/base/common/uri';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
@@ -200,7 +200,7 @@ export interface ITextDocumentShowOptions {
|
||||
}
|
||||
|
||||
export interface IWorkspaceResourceEdit {
|
||||
resource: URI;
|
||||
resource: UriComponents;
|
||||
modelVersionId?: number;
|
||||
edits: {
|
||||
range?: IRange;
|
||||
@@ -210,14 +210,14 @@ export interface IWorkspaceResourceEdit {
|
||||
}
|
||||
|
||||
export interface MainThreadEditorsShape extends IDisposable {
|
||||
$tryShowTextDocument(resource: URI, options: ITextDocumentShowOptions): TPromise<string>;
|
||||
$tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): TPromise<string>;
|
||||
$registerTextEditorDecorationType(key: string, options: editorCommon.IDecorationRenderOptions): void;
|
||||
$removeTextEditorDecorationType(key: string): void;
|
||||
$tryShowEditor(id: string, position: EditorPosition): TPromise<void>;
|
||||
$tryHideEditor(id: string): TPromise<void>;
|
||||
$trySetOptions(id: string, options: ITextEditorConfigurationUpdate): TPromise<any>;
|
||||
$trySetDecorations(id: string, key: string, ranges: editorCommon.IDecorationOptions[]): TPromise<any>;
|
||||
$trySetDecorationsFast(id: string, key: string, ranges: string): TPromise<any>;
|
||||
$trySetDecorationsFast(id: string, key: string, ranges: number[]): TPromise<any>;
|
||||
$tryRevealRange(id: string, range: IRange, revealType: TextEditorRevealType): TPromise<any>;
|
||||
$trySetSelections(id: string, selections: ISelection[]): TPromise<any>;
|
||||
$tryApplyEdits(id: string, modelVersionId: number, edits: editorCommon.ISingleEditOperation[], opts: IApplyEditsOptions): TPromise<boolean>;
|
||||
@@ -673,7 +673,7 @@ export const MainContext = {
|
||||
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs', ProxyType.CustomMarshaller),
|
||||
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments', ProxyType.CustomMarshaller),
|
||||
MainThreadDocumentContentProviders: createMainId<MainThreadDocumentContentProvidersShape>('MainThreadDocumentContentProviders', ProxyType.CustomMarshaller),
|
||||
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors', ProxyType.CustomMarshaller),
|
||||
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors'),
|
||||
MainThreadErrors: createMainId<MainThreadErrorsShape>('MainThreadErrors', ProxyType.CustomMarshaller),
|
||||
MainThreadTreeViews: createMainId<MainThreadTreeViewsShape>('MainThreadTreeViews', ProxyType.CustomMarshaller),
|
||||
MainThreadLanguageFeatures: createMainId<MainThreadLanguageFeaturesShape>('MainThreadLanguageFeatures', ProxyType.CustomMarshaller),
|
||||
|
||||
@@ -435,7 +435,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
return this._proxy.$trySetDecorationsFast(
|
||||
this._id,
|
||||
decorationType.key,
|
||||
/*TODO: marshaller is too slow*/JSON.stringify(_ranges)
|
||||
_ranges
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,15 +324,16 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
$tryApplyWorkspaceEdit(_edits: IWorkspaceResourceEdit[]) {
|
||||
|
||||
for (const { resource, edits } of _edits) {
|
||||
const uri = URI.revive(resource);
|
||||
for (const { newText, range } of edits) {
|
||||
documents.$acceptModelChanged(resource.toString(), {
|
||||
documents.$acceptModelChanged(uri.toString(), {
|
||||
changes: [{
|
||||
range,
|
||||
rangeLength: undefined,
|
||||
text: newText
|
||||
}],
|
||||
eol: undefined,
|
||||
versionId: documents.getDocumentData(resource).version + 1
|
||||
versionId: documents.getDocumentData(uri).version + 1
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user