Skip to content

fix layout overlap issue #20

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 1 commit into from
Jul 21, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
"command": "coderoad.start",
"title": "Start",
"category": "CodeRoad"
},
{
"command": "coderoad.set_layout",
"title": "Set Layout",
"category": "CodeRoad"
}
]
},
Expand Down
24 changes: 12 additions & 12 deletions src/editor/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const COMMANDS = {
RUN_TEST: 'coderoad.run_test',
TEST_PASS: 'coderoad.test_pass',
TEST_FAIL: 'coderoad.test_fail',
SET_LAYOUT: 'coderoad.set_layout',
}

interface CreateCommandProps {
Expand All @@ -29,13 +28,21 @@ interface CreateCommandProps {
position: any
}

const resetLayout = () => {
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{ groups: [{}], size: 0.6 }, { groups: [{}], size: 0.4 }],
})
}

export const createCommands = ({ context, machine, storage, git, position }: CreateCommandProps) => {
// React panel webview
let webview: any

return {
// initialize
[COMMANDS.START]: () => {

let webviewState: 'INITIALIZING' | 'RESTARTING'
if (!webview) {
webviewState = 'INITIALIZING'
Expand Down Expand Up @@ -64,10 +71,7 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
// open React webview
[COMMANDS.OPEN_WEBVIEW]: (column: number = vscode.ViewColumn.Two) => {
// setup 1x1 horizontal layout
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{ groups: [{}], size: 0.6 }, { groups: [{}], size: 0.4 }],
})
resetLayout()
const callback = () => {
machine.send('WEBVIEW_INITIALIZED')
}
Expand Down Expand Up @@ -118,6 +122,9 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
const absoluteFilePath = join(workspaceRoot, relativeFilePath)
const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
// there are times when intialization leave the panel behind any files opened
// ensure the panel is redrawn on the right side first
webview.createOrShow(vscode.ViewColumn.Two)
} catch (error) {
console.log(`Failed to open file ${relativeFilePath}`, error)
}
Expand Down Expand Up @@ -145,12 +152,5 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
[COMMANDS.TEST_FAIL]: () => {
vscode.window.showWarningMessage('FAIL')
},
[COMMANDS.SET_LAYOUT]: () => {
console.log('setLayout')
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{ groups: [{}], size: 0.6 }, { groups: [{}], size: 0.4 }],
})
},
}
}