Skip to content

Commit

Permalink
Fix #4003 Regain focus after creating viewer tab
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Sep 6, 2023
1 parent 383d346 commit 4a9d98b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,29 @@ export class Viewer {
const editorGroup = configuration.get('view.pdf.tab.editorGroup')
// Roughly translate editorGroup to vscode.ViewColumn
let viewColumn: vscode.ViewColumn
let focusAction: string = ''
if (editorGroup === 'current') {
viewColumn = vscode.ViewColumn.Active
} else if (editorGroup === 'right') {
viewColumn = vscode.ViewColumn.Two
focusAction = 'workbench.action.focusLeftGroup'
} else if (editorGroup === 'left') {
viewColumn = vscode.ViewColumn.One
focusAction = 'workbench.action.focusRightGroup'
} else {
// Other locations are not supported by the editor open API -> use right panel as default
viewColumn = vscode.ViewColumn.Two
focusAction = 'workbench.action.focusLeftGroup'
}
const pdfUri = vscode.Uri.file(pdfFile)
const showOptions: vscode.TextDocumentShowOptions = {
viewColumn,
preserveFocus: true
}
await vscode.commands.executeCommand('vscode.openWith', pdfUri, 'latex-workshop-pdf-hook', showOptions)
if (focusAction !== '') {
await vscode.commands.executeCommand(focusAction)
}
}

async openPdfInTab(pdfUri: vscode.Uri, tabEditorGroup: string, preserveFocus: boolean): Promise<void> {
Expand Down

0 comments on commit 4a9d98b

Please sign in to comment.