Merge branch 'master' into aeschli/decoration-attachments

This commit is contained in:
Martin Aeschlimann
2016-06-03 11:41:07 +02:00
360 changed files with 6837 additions and 4670 deletions

View File

@@ -151,10 +151,11 @@ class ExtHostApiCommands {
});
this._register('vscode.previewHtml', (uri: URI, position?: vscode.ViewColumn) => {
return this._commands.executeCommand('_workbench.previewHtml', uri,
typeof position === 'number' ? typeConverters.fromViewColumn(position) : void 0);
this._register('vscode.previewHtml', (uri: URI, position?: vscode.ViewColumn, label?: string) => {
return this._commands.executeCommand('_workbench.previewHtml',
uri,
typeof position === 'number' && typeConverters.fromViewColumn(position),
label);
}, {
description: `
Render the html of the resource in an editor view.
@@ -172,6 +173,7 @@ class ExtHostApiCommands {
args: [
{ name: 'uri', description: 'Uri of the resource to preview.', constraint: value => value instanceof URI || typeof value === 'string' },
{ name: 'column', description: '(optional) Column in which to preview.' },
{ name: 'label', description: '(optional) An human readable string that is used as title for the preview.', constraint: v => typeof v === 'string' || typeof v === 'undefined' }
]
});

View File

@@ -16,12 +16,12 @@ import {Selection, Range, Position, EditorOptions, EndOfLine} from './extHostTyp
import {ISingleEditOperation, ISelection, IRange, IEditor, EditorType, ICommonCodeEditor, ICommonDiffEditor, IDecorationRenderOptions, IDecorationOptions} from 'vs/editor/common/editorCommon';
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {Position as EditorPosition} from 'vs/platform/editor/common/editor';
import {IModelService} from 'vs/editor/common/services/modelService';
import {MainThreadEditorsTracker, TextEditorRevealType, MainThreadTextEditor, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration} from 'vs/workbench/api/node/mainThreadEditors';
import * as TypeConverters from './extHostTypeConverters';
import {TextDocument, TextEditorSelectionChangeEvent, TextEditorOptionsChangeEvent, TextEditorOptions, TextEditorViewColumnChangeEvent, ViewColumn} from 'vscode';
import {EventType} from 'vs/workbench/common/events';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IEventService} from 'vs/platform/event/common/event';
import {equals as arrayEquals} from 'vs/base/common/arrays';
@@ -470,6 +470,7 @@ export class MainThreadEditors {
constructor(
@IThreadService threadService: IThreadService,
@IWorkbenchEditorService workbenchEditorService: IWorkbenchEditorService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@ITelemetryService telemetryService: ITelemetryService,
@ICodeEditorService editorService: ICodeEditorService,
@IEventService eventService: IEventService,
@@ -493,8 +494,8 @@ export class MainThreadEditors {
this._toDispose.push(this._editorTracker.onDidUpdateTextEditors(() => this._updateActiveAndVisibleTextEditors()));
this._toDispose.push(this._editorTracker.onChangedFocusedTextEditor((focusedTextEditorId) => this._updateActiveAndVisibleTextEditors()));
this._toDispose.push(eventService.addListener2(EventType.EDITOR_INPUT_CHANGED, () => this._updateActiveAndVisibleTextEditors()));
this._toDispose.push(eventService.addListener2(EventType.EDITOR_POSITION_CHANGED, () => this._updateActiveAndVisibleTextEditors()));
this._toDispose.push(editorGroupService.onEditorsChanged(() => this._updateActiveAndVisibleTextEditors()));
this._toDispose.push(editorGroupService.onEditorsMoved(() => this._updateActiveAndVisibleTextEditors()));
}
public dispose(): void {

View File

@@ -63,6 +63,20 @@ export class Position {
return result;
}
static is(other: any): other is Position {
if (!other) {
return false;
}
if (other instanceof Position) {
return true;
}
let {line, character} = <Position>other;
if (typeof line === 'number' && typeof character === 'number') {
return true;
}
return false;
}
private _line: number;
private _character: number;
@@ -135,14 +149,50 @@ export class Position {
}
}
translate(lineDelta: number = 0, characterDelta: number = 0): Position {
translate(change: { lineDelta?: number; characterDelta?: number;}): Position;
translate(lineDelta?: number, characterDelta?: number): Position;
translate(lineDeltaOrChange: number | { lineDelta?: number; characterDelta?: number; }, characterDelta: number = 0): Position {
if (lineDeltaOrChange === null || characterDelta === null) {
throw illegalArgument();
}
let lineDelta: number;
if (typeof lineDeltaOrChange === 'undefined') {
lineDelta = 0;
} else if (typeof lineDeltaOrChange === 'number') {
lineDelta = lineDeltaOrChange;
} else {
lineDelta = typeof lineDeltaOrChange.lineDelta === 'number' ? lineDeltaOrChange.lineDelta : 0;
characterDelta = typeof lineDeltaOrChange.characterDelta === 'number' ? lineDeltaOrChange.characterDelta : 0;
}
if (lineDelta === 0 && characterDelta === 0) {
return this;
}
return new Position(this.line + lineDelta, this.character + characterDelta);
}
with(line: number = this.line, character: number = this.character): Position {
with(change: { line?: number; character?: number; }): Position;
with(line?: number, character?: number): Position;
with(lineOrChange: number | { line?: number; character?: number; }, character: number = this.character): Position {
if (lineOrChange === null || character === null) {
throw illegalArgument();
}
let line: number;
if (typeof lineOrChange === 'undefined') {
line = this.line;
} else if (typeof lineOrChange === 'number') {
line = lineOrChange;
} else {
line = typeof lineOrChange.line === 'number' ? lineOrChange.line : this.line;
character = typeof lineOrChange.character === 'number' ? lineOrChange.character : this.character;
}
if (line === this.line && character === this.character) {
return this;
}
@@ -246,7 +296,26 @@ export class Range {
return this._start.line === this._end.line;
}
with(start: Position = this.start, end: Position = this.end): Range {
with(change: { start?: Position, end?: Position }): Range;
with(start?: Position, end?: Position): Range;
with(startOrChange: Position | { start?: Position, end?: Position }, end: Position = this.end): Range {
if (startOrChange === null || end === null) {
throw illegalArgument();
}
let start: Position;
if (!startOrChange) {
start = this.start;
} else if (Position.is(startOrChange)) {
start = startOrChange;
} else {
start = startOrChange.start || this.start;
end = startOrChange.end || this.end;
}
if (start.isEqual(this._start) && end.isEqual(this.end)) {
return this;
}