Skip to content

Commit

Permalink
fix #6800: showTextDocument api should check columnOrOptions type
Browse files Browse the repository at this point in the history
Signed-off-by: Gan Lin <ganlinbupt@163.com>
  • Loading branch information
Gan Lin authored and akosyakov committed Jan 6, 2020
1 parent ec2a866 commit 881965a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,19 @@ export function createAPIFactory(
return editors.onDidChangeTextEditorVisibleRanges(listener, thisArg, disposables);
},
async showTextDocument(documentArg: theia.TextDocument | Uri,
optionsArg?: theia.TextDocumentShowOptions | theia.ViewColumn,
columnOrOptions?: theia.TextDocumentShowOptions | theia.ViewColumn,
preserveFocus?: boolean
): Promise<theia.TextEditor> {
let documentOptions: theia.TextDocumentShowOptions | undefined;
const uri: Uri = documentArg instanceof Uri ? documentArg : documentArg.uri;
if (optionsArg) {
// tslint:disable-next-line:no-any
const optionsAny: any = optionsArg;
if (optionsAny.preserveFocus || optionsAny.preview || optionsAny.selection || optionsAny.viewColumn) {
documentOptions = optionsArg as theia.TextDocumentShowOptions;
}
if (typeof columnOrOptions === 'number') {
documentOptions = {
viewColumn: columnOrOptions
};
} else if (columnOrOptions && (columnOrOptions.preserveFocus || columnOrOptions.preview || columnOrOptions.selection || columnOrOptions.viewColumn)) {
documentOptions = {
...columnOrOptions
};
}
if (preserveFocus) {
if (documentOptions) {
Expand Down

0 comments on commit 881965a

Please sign in to comment.