mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
tsfmt - src
This commit is contained in:
@@ -5,16 +5,16 @@
|
||||
'use strict';
|
||||
|
||||
import EditorCommon = require('vs/editor/common/editorCommon');
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import {IEditor} from 'vs/platform/editor/common/editor';
|
||||
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {RunOnceScheduler} from 'vs/base/common/async';
|
||||
import {IdGenerator} from 'vs/base/common/idGenerator';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import {EndOfLine, TextEditorLineNumbersStyle} from 'vs/workbench/api/node/extHostTypes';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IEditor } from 'vs/platform/editor/common/editor';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { IdGenerator } from 'vs/base/common/idGenerator';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { EndOfLine, TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes';
|
||||
|
||||
export interface ITextEditorConfigurationUpdate {
|
||||
tabSize?: number | string;
|
||||
@@ -29,7 +29,7 @@ export interface IResolvedTextEditorConfiguration {
|
||||
lineNumbers: TextEditorLineNumbersStyle;
|
||||
}
|
||||
|
||||
function configurationsEqual(a:IResolvedTextEditorConfiguration, b:IResolvedTextEditorConfiguration) {
|
||||
function configurationsEqual(a: IResolvedTextEditorConfiguration, b: IResolvedTextEditorConfiguration) {
|
||||
if (a && !b || !a && b) {
|
||||
return false;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ export class MainThreadTextEditor {
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
model:EditorCommon.IModel,
|
||||
codeEditor:EditorCommon.ICommonCodeEditor,
|
||||
focusTracker:IFocusTracker,
|
||||
model: EditorCommon.IModel,
|
||||
codeEditor: EditorCommon.ICommonCodeEditor,
|
||||
focusTracker: IFocusTracker,
|
||||
modelService: IModelService
|
||||
) {
|
||||
this._id = id;
|
||||
@@ -101,7 +101,7 @@ export class MainThreadTextEditor {
|
||||
this._onSelectionChanged = new Emitter<ISelectionChangeEvent>();
|
||||
this._onConfigurationChanged = new Emitter<IResolvedTextEditorConfiguration>();
|
||||
|
||||
this._lastSelection = [ new Selection(1,1,1,1) ];
|
||||
this._lastSelection = [new Selection(1, 1, 1, 1)];
|
||||
this._modelListeners = [];
|
||||
this._modelListeners.push(this._model.onDidChangeOptions((e) => {
|
||||
this._setConfiguration(this._readConfiguration(this._model, this._codeEditor));
|
||||
@@ -126,11 +126,11 @@ export class MainThreadTextEditor {
|
||||
return this._model;
|
||||
}
|
||||
|
||||
public hasCodeEditor(codeEditor:EditorCommon.ICommonCodeEditor): boolean {
|
||||
public hasCodeEditor(codeEditor: EditorCommon.ICommonCodeEditor): boolean {
|
||||
return (this._codeEditor === codeEditor);
|
||||
}
|
||||
|
||||
public setCodeEditor(codeEditor:EditorCommon.ICommonCodeEditor): void {
|
||||
public setCodeEditor(codeEditor: EditorCommon.ICommonCodeEditor): void {
|
||||
if (this.hasCodeEditor(codeEditor)) {
|
||||
// Nothing to do...
|
||||
return;
|
||||
@@ -188,7 +188,7 @@ export class MainThreadTextEditor {
|
||||
return this._lastSelection;
|
||||
}
|
||||
|
||||
public setSelections(selections:EditorCommon.ISelection[]): void {
|
||||
public setSelections(selections: EditorCommon.ISelection[]): void {
|
||||
if (this._codeEditor) {
|
||||
this._codeEditor.setSelections(selections);
|
||||
return;
|
||||
@@ -201,7 +201,7 @@ export class MainThreadTextEditor {
|
||||
return this._configuration;
|
||||
}
|
||||
|
||||
private _setIndentConfiguration(newConfiguration:ITextEditorConfigurationUpdate): void {
|
||||
private _setIndentConfiguration(newConfiguration: ITextEditorConfigurationUpdate): void {
|
||||
if (newConfiguration.tabSize === 'auto' || newConfiguration.insertSpaces === 'auto') {
|
||||
// one of the options was set to 'auto' => detect indentation
|
||||
|
||||
@@ -240,7 +240,7 @@ export class MainThreadTextEditor {
|
||||
this._model.updateOptions(newOpts);
|
||||
}
|
||||
|
||||
public setConfiguration(newConfiguration:ITextEditorConfigurationUpdate): void {
|
||||
public setConfiguration(newConfiguration: ITextEditorConfigurationUpdate): void {
|
||||
this._setIndentConfiguration(newConfiguration);
|
||||
|
||||
if (newConfiguration.cursorStyle) {
|
||||
@@ -280,7 +280,7 @@ export class MainThreadTextEditor {
|
||||
}
|
||||
}
|
||||
|
||||
public setDecorations(key: string, ranges:EditorCommon.IDecorationOptions[]): void {
|
||||
public setDecorations(key: string, ranges: EditorCommon.IDecorationOptions[]): void {
|
||||
if (!this._codeEditor) {
|
||||
console.warn('setDecorations on invisible editor');
|
||||
return;
|
||||
@@ -288,7 +288,7 @@ export class MainThreadTextEditor {
|
||||
this._codeEditor.setDecorations(key, ranges);
|
||||
}
|
||||
|
||||
public revealRange(range:EditorCommon.IRange, revealType:TextEditorRevealType): void {
|
||||
public revealRange(range: EditorCommon.IRange, revealType: TextEditorRevealType): void {
|
||||
if (!this._codeEditor) {
|
||||
console.warn('revealRange on invisible editor');
|
||||
return;
|
||||
@@ -304,7 +304,7 @@ export class MainThreadTextEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private _readConfiguration(model:EditorCommon.IModel, codeEditor:EditorCommon.ICommonCodeEditor): IResolvedTextEditorConfiguration {
|
||||
private _readConfiguration(model: EditorCommon.IModel, codeEditor: EditorCommon.ICommonCodeEditor): IResolvedTextEditorConfiguration {
|
||||
if (model.isDisposed()) {
|
||||
// shutdown time
|
||||
return this._configuration;
|
||||
@@ -333,7 +333,7 @@ export class MainThreadTextEditor {
|
||||
};
|
||||
}
|
||||
|
||||
private _setConfiguration(newConfiguration:IResolvedTextEditorConfiguration): void {
|
||||
private _setConfiguration(newConfiguration: IResolvedTextEditorConfiguration): void {
|
||||
if (configurationsEqual(this._configuration, newConfiguration)) {
|
||||
return;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ export class MainThreadTextEditor {
|
||||
return editor.getControl() === this._codeEditor;
|
||||
}
|
||||
|
||||
public applyEdits(versionIdCheck:number, edits:EditorCommon.ISingleEditOperation[], opts:IApplyEditsOptions): boolean {
|
||||
public applyEdits(versionIdCheck: number, edits: EditorCommon.ISingleEditOperation[], opts: IApplyEditsOptions): boolean {
|
||||
if (this._model.getVersionId() !== versionIdCheck) {
|
||||
console.warn('Model has changed in the meantime!');
|
||||
// throw new Error('Model has changed in the meantime!');
|
||||
@@ -405,10 +405,10 @@ export class MainThreadEditorsTracker {
|
||||
private _codeEditorService: ICodeEditorService;
|
||||
private _modelService: IModelService;
|
||||
private _updateMapping: RunOnceScheduler;
|
||||
private _editorModelChangeListeners: {[editorId:string]:IDisposable;};
|
||||
private _editorModelChangeListeners: { [editorId: string]: IDisposable; };
|
||||
|
||||
private _model2TextEditors: {
|
||||
[modelUri:string]: MainThreadTextEditor[];
|
||||
[modelUri: string]: MainThreadTextEditor[];
|
||||
};
|
||||
private _focusedTextEditorId: string;
|
||||
private _visibleTextEditorIds: string[];
|
||||
@@ -420,8 +420,8 @@ export class MainThreadEditorsTracker {
|
||||
private _focusTracker: IFocusTracker;
|
||||
|
||||
constructor(
|
||||
editorService:ICodeEditorService,
|
||||
modelService:IModelService
|
||||
editorService: ICodeEditorService,
|
||||
modelService: IModelService
|
||||
) {
|
||||
this._codeEditorService = editorService;
|
||||
this._modelService = modelService;
|
||||
@@ -476,7 +476,7 @@ export class MainThreadEditorsTracker {
|
||||
let allModels = this._modelService.getModels();
|
||||
// Same filter as in extHostDocuments
|
||||
allModels = allModels.filter((model) => !model.isTooLargeForHavingARichMode());
|
||||
let allModelsMap: { [modelUri:string]: EditorCommon.IModel; } = Object.create(null);
|
||||
let allModelsMap: { [modelUri: string]: EditorCommon.IModel; } = Object.create(null);
|
||||
allModels.forEach((model) => {
|
||||
allModelsMap[model.uri.toString()] = model;
|
||||
});
|
||||
@@ -602,7 +602,7 @@ export class MainThreadEditorsTracker {
|
||||
return result;
|
||||
}
|
||||
|
||||
private _setFocusedTextEditorId(focusedTextEditorId:string): void {
|
||||
private _setFocusedTextEditorId(focusedTextEditorId: string): void {
|
||||
if (this._focusedTextEditorId === focusedTextEditorId) {
|
||||
// no change
|
||||
return;
|
||||
@@ -674,7 +674,7 @@ export class MainThreadEditorsTracker {
|
||||
return this._onDidChangeFocusedTextEditor.event;
|
||||
}
|
||||
|
||||
public findTextEditorIdFor(codeEditor:EditorCommon.ICommonCodeEditor): string {
|
||||
public findTextEditorIdFor(codeEditor: EditorCommon.ICommonCodeEditor): string {
|
||||
let modelUris = Object.keys(this._model2TextEditors);
|
||||
for (let i = 0, len = modelUris.length; i < len; i++) {
|
||||
let editors = this._model2TextEditors[modelUris[i]];
|
||||
@@ -688,23 +688,23 @@ export class MainThreadEditorsTracker {
|
||||
return null;
|
||||
}
|
||||
|
||||
public registerTextEditorDecorationType(key:string, options: EditorCommon.IDecorationRenderOptions): void {
|
||||
public registerTextEditorDecorationType(key: string, options: EditorCommon.IDecorationRenderOptions): void {
|
||||
this._codeEditorService.registerDecorationType(key, options);
|
||||
}
|
||||
|
||||
public removeTextEditorDecorationType(key:string): void {
|
||||
public removeTextEditorDecorationType(key: string): void {
|
||||
this._codeEditorService.removeDecorationType(key);
|
||||
}
|
||||
}
|
||||
|
||||
interface IVisibleModels {
|
||||
[modelUri:string]: {
|
||||
[modelUri: string]: {
|
||||
model: EditorCommon.IModel;
|
||||
codeEditors: EditorCommon.ICommonCodeEditor[];
|
||||
};
|
||||
}
|
||||
|
||||
function strcmp(a:string, b:string): number {
|
||||
function strcmp(a: string, b: string): number {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user