File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { AuthenticationProviderTobikoCloud } from './auth/auth'
1212import { signOut } from './commands/signout'
1313import { signIn } from './commands/signin'
1414import { signInSpecifyFlow } from './commands/signinSpecifyFlow'
15+ import { openTestQuery } from './commands/openTestQuery'
1516import { isErr } from '@bus/result'
1617import {
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
You can’t perform that action at this time.
0 commit comments