Skip to content

Commit

Permalink
Fix #4054 Elegant custom editor group logic
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Nov 4, 2023
1 parent 197f94e commit f8e8687
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,25 @@ export class Viewer {
viewColumn: vscode.ViewColumn.Active,
preserveFocus: true
}
await vscode.commands.executeCommand('vscode.openWith', pdfUri, 'latex-workshop-pdf-hook', showOptions)
await moveActiveEditor(editorGroup, true)
if (editorGroup === 'left') {
const currentColumn = vscode.window.activeTextEditor?.viewColumn
if (currentColumn && currentColumn > 1) {
showOptions.viewColumn = currentColumn - 1
await vscode.commands.executeCommand('vscode.openWith', pdfUri, 'latex-workshop-pdf-hook', showOptions)
} else {
await vscode.commands.executeCommand('vscode.openWith', pdfUri, 'latex-workshop-pdf-hook', showOptions)
if (currentColumn === vscode.ViewColumn.One) {
await moveActiveEditor('left', true)
}
}
} else if (editorGroup === 'right') {
const currentColumn = vscode.window.activeTextEditor?.viewColumn
showOptions.viewColumn = (currentColumn ?? 0) + 1
await vscode.commands.executeCommand('vscode.openWith', pdfUri, 'latex-workshop-pdf-hook', showOptions)
} else {
await vscode.commands.executeCommand('vscode.openWith', pdfUri, 'latex-workshop-pdf-hook', showOptions)
await moveActiveEditor(editorGroup, true)
}
logger.log(`Open PDF tab for ${pdfUri.toString(true)}`)
}

Expand Down

0 comments on commit f8e8687

Please sign in to comment.