mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
type converters, use namespace for ViewColumn
This commit is contained in:
@@ -32,7 +32,7 @@ export class PreviewHTMLAPICommand {
|
||||
public static execute(executor: ICommandsExecutor, uri: URI, position?: vscode.ViewColumn, label?: string, options?: any): Thenable<any> {
|
||||
return executor.executeCommand('_workbench.previewHtml',
|
||||
uri,
|
||||
typeof position === 'number' && typeConverters.fromViewColumn(position),
|
||||
typeof position === 'number' && typeConverters.ViewColumn.from(position),
|
||||
label,
|
||||
options
|
||||
);
|
||||
@@ -60,7 +60,7 @@ export class DiffAPICommand {
|
||||
label,
|
||||
undefined,
|
||||
typeConverters.toTextEditorOptions(options),
|
||||
options ? typeConverters.fromViewColumn(options.viewColumn) : undefined
|
||||
options ? typeConverters.ViewColumn.from(options.viewColumn) : undefined
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -74,10 +74,10 @@ export class OpenAPICommand {
|
||||
|
||||
if (columnOrOptions) {
|
||||
if (typeof columnOrOptions === 'number') {
|
||||
column = typeConverters.fromViewColumn(columnOrOptions);
|
||||
column = typeConverters.ViewColumn.from(columnOrOptions);
|
||||
} else {
|
||||
options = typeConverters.toTextEditorOptions(columnOrOptions);
|
||||
column = typeConverters.fromViewColumn(columnOrOptions.viewColumn);
|
||||
column = typeConverters.ViewColumn.from(columnOrOptions.viewColumn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
|
||||
data.selections.map(typeConverters.Selection.to),
|
||||
data.options,
|
||||
data.visibleRanges.map(typeConverters.Range.to),
|
||||
typeConverters.toViewColumn(data.editorPosition)
|
||||
typeConverters.ViewColumn.to(data.editorPosition)
|
||||
);
|
||||
this._editors.set(data.id, editor);
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
|
||||
@deprecated('TextEditor.show') show(column: vscode.ViewColumn) {
|
||||
this._proxy.$tryShowEditor(this._id, TypeConverters.fromViewColumn(column));
|
||||
this._proxy.$tryShowEditor(this._id, TypeConverters.ViewColumn.from(column));
|
||||
}
|
||||
|
||||
@deprecated('TextEditor.hide') hide() {
|
||||
|
||||
@@ -61,12 +61,12 @@ export class ExtHostEditors implements ExtHostEditorsShape {
|
||||
let options: ITextDocumentShowOptions;
|
||||
if (typeof columnOrOptions === 'number') {
|
||||
options = {
|
||||
position: TypeConverters.fromViewColumn(columnOrOptions),
|
||||
position: TypeConverters.ViewColumn.from(columnOrOptions),
|
||||
preserveFocus
|
||||
};
|
||||
} else if (typeof columnOrOptions === 'object') {
|
||||
options = {
|
||||
position: TypeConverters.fromViewColumn(columnOrOptions.viewColumn),
|
||||
position: TypeConverters.ViewColumn.from(columnOrOptions.viewColumn),
|
||||
preserveFocus: columnOrOptions.preserveFocus,
|
||||
selection: typeof columnOrOptions.selection === 'object' ? TypeConverters.Range.from(columnOrOptions.selection) : undefined,
|
||||
pinned: typeof columnOrOptions.preview === 'boolean' ? !columnOrOptions.preview : undefined
|
||||
@@ -159,7 +159,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
|
||||
$acceptEditorPositionData(data: ITextEditorPositionData): void {
|
||||
for (let id in data) {
|
||||
let textEditor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
let viewColumn = TypeConverters.toViewColumn(data[id]);
|
||||
let viewColumn = TypeConverters.ViewColumn.to(data[id]);
|
||||
if (textEditor.viewColumn !== viewColumn) {
|
||||
textEditor._acceptViewColumn(viewColumn);
|
||||
this._onDidChangeTextEditorViewColumn.fire({ textEditor, viewColumn });
|
||||
|
||||
@@ -144,33 +144,34 @@ export namespace DiagnosticSeverity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function fromViewColumn(column?: vscode.ViewColumn): EditorPosition {
|
||||
let editorColumn = EditorPosition.ONE;
|
||||
if (typeof column !== 'number') {
|
||||
// stick with ONE
|
||||
} else if (column === <number>types.ViewColumn.Two) {
|
||||
editorColumn = EditorPosition.TWO;
|
||||
} else if (column === <number>types.ViewColumn.Three) {
|
||||
editorColumn = EditorPosition.THREE;
|
||||
} else if (column === <number>types.ViewColumn.Active) {
|
||||
editorColumn = undefined;
|
||||
export namespace ViewColumn {
|
||||
export function from(column?: vscode.ViewColumn): EditorPosition {
|
||||
let editorColumn = EditorPosition.ONE;
|
||||
if (typeof column !== 'number') {
|
||||
// stick with ONE
|
||||
} else if (column === <number>types.ViewColumn.Two) {
|
||||
editorColumn = EditorPosition.TWO;
|
||||
} else if (column === <number>types.ViewColumn.Three) {
|
||||
editorColumn = EditorPosition.THREE;
|
||||
} else if (column === <number>types.ViewColumn.Active) {
|
||||
editorColumn = undefined;
|
||||
}
|
||||
return editorColumn;
|
||||
}
|
||||
return editorColumn;
|
||||
}
|
||||
|
||||
export function toViewColumn(position?: EditorPosition): vscode.ViewColumn {
|
||||
if (typeof position !== 'number') {
|
||||
export function to(position?: EditorPosition): vscode.ViewColumn {
|
||||
if (typeof position !== 'number') {
|
||||
return undefined;
|
||||
}
|
||||
if (position === EditorPosition.ONE) {
|
||||
return <number>types.ViewColumn.One;
|
||||
} else if (position === EditorPosition.TWO) {
|
||||
return <number>types.ViewColumn.Two;
|
||||
} else if (position === EditorPosition.THREE) {
|
||||
return <number>types.ViewColumn.Three;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
if (position === EditorPosition.ONE) {
|
||||
return <number>types.ViewColumn.One;
|
||||
} else if (position === EditorPosition.TWO) {
|
||||
return <number>types.ViewColumn.Two;
|
||||
} else if (position === EditorPosition.THREE) {
|
||||
return <number>types.ViewColumn.Three;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isDecorationOptions(something: any): something is vscode.DecorationOptions {
|
||||
|
||||
@@ -174,7 +174,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
|
||||
public reveal(viewColumn?: vscode.ViewColumn, preserveFocus?: boolean): void {
|
||||
this.assertNotDisposed();
|
||||
this._proxy.$reveal(this._handle,
|
||||
viewColumn ? typeConverters.fromViewColumn(viewColumn) : undefined,
|
||||
viewColumn ? typeConverters.ViewColumn.from(viewColumn) : undefined,
|
||||
!!preserveFocus);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
|
||||
const viewColumn = typeof showOptions === 'object' ? showOptions.viewColumn : showOptions;
|
||||
const webviewShowOptions = {
|
||||
viewColumn: typeConverters.fromViewColumn(viewColumn),
|
||||
viewColumn: typeConverters.ViewColumn.from(viewColumn),
|
||||
preserveFocus: typeof showOptions === 'object' && !!showOptions.preserveFocus
|
||||
};
|
||||
|
||||
@@ -250,7 +250,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
$onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, visible: boolean, position: Position): void {
|
||||
const panel = this.getWebviewPanel(handle);
|
||||
if (panel) {
|
||||
const viewColumn = typeConverters.toViewColumn(position);
|
||||
const viewColumn = typeConverters.ViewColumn.to(position);
|
||||
if (panel.visible !== visible || panel.viewColumn !== viewColumn) {
|
||||
panel._setVisible(visible);
|
||||
panel._setViewColumn(viewColumn);
|
||||
@@ -282,7 +282,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
}
|
||||
|
||||
const webview = new ExtHostWebview(webviewHandle, this._proxy, options);
|
||||
const revivedPanel = new ExtHostWebviewPanel(webviewHandle, this._proxy, viewType, title, typeConverters.toViewColumn(position), options, webview);
|
||||
const revivedPanel = new ExtHostWebviewPanel(webviewHandle, this._proxy, viewType, title, typeConverters.ViewColumn.to(position), options, webview);
|
||||
this._webviewPanels.set(webviewHandle, revivedPanel);
|
||||
return serializer.deserializeWebviewPanel(revivedPanel, state);
|
||||
}
|
||||
@@ -306,4 +306,4 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
private getWebviewPanel(handle: WebviewPanelHandle): ExtHostWebviewPanel | undefined {
|
||||
return this._webviewPanels.get(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user