Skip to content

Feature/window sizes #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix window positioning issue
  • Loading branch information
ShMcK committed Jul 9, 2019
commit d8696b52eb165bf14035864b10d33fa37c616ab9
21 changes: 19 additions & 2 deletions src/editor/ReactWebView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ReactWebView {
this.extensionPath = extensionPath

// Create and show a new webview panel
this.panel = this.createWebviewPanel(vscode.ViewColumn.One)
this.panel = this.createWebviewPanel(vscode.ViewColumn.Two)

// Set the webview's initial html content
this.panel.webview.html = this.getHtmlForWebview()
Expand All @@ -28,7 +28,24 @@ class ReactWebView {
// Handle messages from the webview
const onReceive = (action: string | CR.Action) => vscode.commands.executeCommand('coderoad.receive_action', action)
this.panel.webview.onDidReceiveMessage(onReceive, null, this.disposables)
console.log('webview loaded')

// update panel on changes
const updateWindows = () => {
vscode.commands.executeCommand('vscode.setEditorLayout', { orientation: 0, groups: [{ groups: [{}], size: 0.6 }, { groups: [{}], size: 0.4 }] })
this.panel.reveal(vscode.ViewColumn.Two)
}
// prevents new panels from going ontop of coderoad panel
vscode.window.onDidChangeActiveTextEditor((param) => {
if (!param || param.viewColumn !== vscode.ViewColumn.Two) {
updateWindows()
}
})
// prevents moving coderoad panel on top of left panel
vscode.window.onDidChangeVisibleTextEditors((param) => {
updateWindows()
})

// TODO: prevent window from moving to the left when no windows remain on rights
}

public createOrShow(column: number): void {
Expand Down