Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix/editor windows#39

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 3 commits intomasterfromfix/editor-windows
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsrc/actions/setupActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,7 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
// await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
// // there are times when initialization leave the panel behind any files opened
// // ensure the panel is redrawn on the right side first
// // webview.createOrShow(vscode.ViewColumn.Two)
// // webview.createOrShow()
// } catch (error) {
// console.log(`Failed to open file ${filePath}`, error)
// }
Expand Down
46 changes: 24 additions & 22 deletionssrc/editor/ReactWebView.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,7 +35,7 @@ class ReactWebView {
this.extensionPath = extensionPath

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

// Set the webview initial html content
this.render()
Expand All@@ -46,23 +46,16 @@ class ReactWebView {


// update panel on changes
const updateWindows = () => {
vscode.commands.executeCommand('coderoad.open_webview')
}
//const updateWindows = () => {
//vscode.commands.executeCommand('coderoad.open_webview')
//}

// prevents new panels from going on top of coderoad panel
vscode.window.onDidChangeActiveTextEditor((textEditor?: vscode.TextEditor) => {
// console.log('onDidChangeActiveTextEditor')
// console.log(textEditor)
if (!textEditor || textEditor.viewColumn !== vscode.ViewColumn.Two) {
updateWindows()
}
})
// // prevents moving coderoad panel on top of left panel
vscode.window.onDidChangeVisibleTextEditors((textEditor: vscode.TextEditor[]) => {
// console.log('onDidChangeVisibleTextEditors')
updateWindows()
})
// // // prevents moving coderoad panel on top of left panel
// vscode.window.onDidChangeVisibleTextEditors((textEditors: vscode.TextEditor[]) => {
// console.log('onDidChangeVisibleTextEditors')
// console.log(textEditors)
// // updateWindows()
// })

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

Expand All@@ -81,13 +74,21 @@ class ReactWebView {
this.send = this.channel.send
}

public createOrShow(column: number): void {
public createOrShow(): void {
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{groups: [{}], size: 0.6}, {groups: [{}], size: 0.4}],
})
// If we already have a panel, show it.
// Otherwise, create a new panel.

if (this.panel && this.panel.webview) {
this.panel.reveal(column)
if (!this.loaded) {
this.panel.reveal(vscode.ViewColumn.Two)
this.loaded = true
}
} else {
this.panel = this.createWebviewPanel(column)
this.panel = this.createWebviewPanel()
}
}

Expand All@@ -98,7 +99,7 @@ class ReactWebView {
Promise.all(this.disposables.map((x) => x.dispose()))
}

private createWebviewPanel = (column: number): vscode.WebviewPanel => {
private createWebviewPanel = (): vscode.WebviewPanel => {
const viewType = 'CodeRoad'
const title = 'CodeRoad'
const config = {
Expand All@@ -109,7 +110,8 @@ class ReactWebView {
// prevents destroying the window when it is in the background
retainContextWhenHidden: true,
}
return vscode.window.createWebviewPanel(viewType, title, column, config)
this.loaded = true
return vscode.window.createWebviewPanel(viewType, title, vscode.ViewColumn.Two, config)
}

private render = async (): Promise<void> => {
Expand Down
11 changes: 2 additions & 9 deletionssrc/editor/commands.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,16 +47,9 @@ export const createCommands = ({extensionPath, workspaceState, workspaceRoot}: C
})
},
// open React webview
[COMMANDS.OPEN_WEBVIEW]: (column: number = vscode.ViewColumn.Two) => {
[COMMANDS.OPEN_WEBVIEW]: () => {
// setup 1x1 horizontal layout

// reset layout
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{groups: [{}], size: 0.6}, {groups: [{}], size: 0.4}],
})

webview.createOrShow(column)
webview.createOrShow()
},
[COMMANDS.SET_CURRENT_STEP]: ({stepId}: {stepId: string}) => {
// NOTE: as async, may sometimes be inaccurate
Expand Down
6 changes: 6 additions & 0 deletionssrc/editor/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,12 @@ class Editor {
console.log('ACTIVATE!')
this.vscodeExt = vscodeExt

// set out 60/40 layout
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{groups: [{}], size: 0.6}, {groups: [{}], size: 0.4}],
})

// commands
this.activateCommands()

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp