From 2b4b23b231d62f30a4d34190efee8fb421e6364f Mon Sep 17 00:00:00 2001 From: Coteh Date: Fri, 16 Jun 2017 22:58:08 -0400 Subject: [PATCH] Add placement configuration of show_query --- SQLTools.sublime-settings | 5 ++++- SQLToolsAPI/Command.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/SQLTools.sublime-settings b/SQLTools.sublime-settings index 2e11980..e578a38 100644 --- a/SQLTools.sublime-settings +++ b/SQLTools.sublime-settings @@ -8,7 +8,10 @@ "show_result_on_window" : false, "clear_output" : true, "safe_limit" : false, - "show_query" : false, + "show_query" : { + "enabled": false, + "placement": "top" + }, "expand_to_paragraph" : false, "use_streams" : false, // use streams for results /** diff --git a/SQLToolsAPI/Command.py b/SQLToolsAPI/Command.py index e5ef990..b027992 100644 --- a/SQLToolsAPI/Command.py +++ b/SQLToolsAPI/Command.py @@ -92,9 +92,18 @@ def run(self): resultString += errors.decode(self.encoding, 'replace').replace('\r', '') - if 'show_query' in self.options and self.options['show_query']: - formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) - resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) + if 'show_query' in self.options: + if isinstance(self.options['show_query'], dict): + if 'enabled' not in self.options['show_query'] or self.options['show_query']['enabled']: + formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) + if ('placement' in self.options['show_query'] + and self.options['show_query']['placement'] == "bottom"): + resultString = "{0}\n{1}".format(resultString, formattedQueryInfo) + else: # top, by default + resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) + elif isinstance(self.options['show_query'], bool) and self.options['show_query']: + formattedQueryInfo = self._formatShowQuery(self.query, queryTimerStart, queryTimerEnd) + resultString = "{0}\n{1}".format(formattedQueryInfo, resultString) self.callback(resultString)