Skip to content

Commit 2e05200

Browse files
committed
feat(vscode): add ability to render model
1 parent c5d3bdb commit 2e05200

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

vscode/extension/package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,23 @@
8787
"command": "sqlmesh.signout",
8888
"title": "Sign out from Tobiko Cloud",
8989
"description": "SQLMesh"
90+
},
91+
{
92+
"command": "sqlmesh.openTestQuery",
93+
"title": "Open Test Query",
94+
"description": "Opens a new SQL editor with a test query",
95+
"icon": "$(database)"
9096
}
91-
]
97+
],
98+
"menus": {
99+
"editor/title": [
100+
{
101+
"command": "sqlmesh.openTestQuery",
102+
"when": "resourceExtname == .sql",
103+
"group": "navigation"
104+
}
105+
]
106+
}
92107
},
93108
"scripts": {
94109
"ci": "pnpm run lint && pnpm run compile",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as vscode from 'vscode'
2+
3+
export function openTestQuery() {
4+
return async () => {
5+
// Get the current active editor
6+
const activeEditor = vscode.window.activeTextEditor
7+
8+
// Create a new untitled document with SQL language
9+
const document = await vscode.workspace.openTextDocument({
10+
language: 'sql',
11+
content: 'SELECT * FROM test'
12+
})
13+
14+
// Determine the view column for side-by-side display
15+
let viewColumn: vscode.ViewColumn
16+
if (activeEditor) {
17+
// Open beside the current editor
18+
viewColumn = activeEditor.viewColumn
19+
? activeEditor.viewColumn + 1
20+
: vscode.ViewColumn.Two
21+
} else {
22+
// If no active editor, open in column two
23+
viewColumn = vscode.ViewColumn.Two
24+
}
25+
26+
// Open the document in the editor as a preview (preview: true is default)
27+
await vscode.window.showTextDocument(document, {
28+
viewColumn: viewColumn,
29+
preview: true,
30+
preserveFocus: false
31+
})
32+
}
33+
}

vscode/extension/src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { AuthenticationProviderTobikoCloud } from './auth/auth'
1212
import { signOut } from './commands/signout'
1313
import { signIn } from './commands/signin'
1414
import { signInSpecifyFlow } from './commands/signinSpecifyFlow'
15+
import { openTestQuery } from './commands/openTestQuery'
1516
import { isErr } from '@bus/result'
1617
import {
1718
handleNotSginedInError,
@@ -61,6 +62,9 @@ export async function activate(context: vscode.ExtensionContext) {
6162
context.subscriptions.push(
6263
vscode.commands.registerCommand('sqlmesh.format', format(authProvider)),
6364
)
65+
context.subscriptions.push(
66+
vscode.commands.registerCommand('sqlmesh.openTestQuery', openTestQuery()),
67+
)
6468

6569
lspClient = new LSPClient()
6670

0 commit comments

Comments
 (0)