@@ -128,6 +128,13 @@ def display(content, name="SQLTools Result"):
128128 resultContainer .run_command ('append' , {'characters' : content })
129129 resultContainer .set_read_only (True )
130130
131+ @staticmethod
132+ def toBuffer (content , name = "" , suffix = "SQLTools Saved Query" ):
133+ resultContainer = STM .Window ().new_file ()
134+ resultContainer .set_name (((name + " - " ) if name != "" else "" ) + suffix )
135+ resultContainer .set_syntax_file ('Packages/SQL/SQL.tmLanguage' )
136+ resultContainer .run_command ('append' , {'characters' : content })
137+
131138#
132139# Commands
133140#
@@ -180,7 +187,8 @@ def run(self):
180187 STM .Storage .promptQueryAlias ()
181188
182189class StListQueries (sublime_plugin .WindowCommand ):
183- def run (self ):
190+ def run (self , mode = "run" ):
191+ print (mode )
184192 if not ST .conn :
185193 ST .showConnectionMenu ()
186194 return
@@ -197,7 +205,10 @@ def run(self):
197205 queriesArray .append ([alias , query ])
198206 queriesArray .sort ()
199207 try :
200- STM .Window ().show_quick_panel (queriesArray , lambda index : ST .conn .execute (queriesArray [index ][1 ], ST .display ) if index != - 1 else None )
208+ if mode == "run" :
209+ STM .Window ().show_quick_panel (queriesArray , lambda index : ST .conn .execute (queriesArray [index ][1 ], ST .display ) if index != - 1 else None )
210+ else :
211+ STM .Window ().show_quick_panel (queriesArray , lambda index : ST .toBuffer (queriesArray [index ][1 ], queriesArray [index ][0 ]) if index != - 1 else None )
201212 except Exception :
202213 pass
203214
@@ -223,8 +234,12 @@ class StFormat(sublime_plugin.TextCommand):
223234 def run (self , edit ):
224235 STM .Selection .formatSql (edit )
225236
237+ class StVersion (sublime_plugin .WindowCommand ):
238+ def run (self ):
239+ sublime .message_dialog ('Using SQLTools ' + STM .Const .VERSION )
240+
226241def plugin_loaded ():
227- STM .Log .debug (__name__ + ' loaded successfully' )
242+ STM .Log .debug ('%s loaded successfully' % ( __name__ ) )
228243 try :
229244 ST .bootstrap ()
230245 except Exception as e :
0 commit comments