diff --git a/packages/extension/package.json b/packages/extension/package.json index 044355c60..966e0cb77 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -749,6 +749,11 @@ "description": "Maximum number of records to return in results.", "default": 50 }, + "sqltools.results.showConsoleOnError": { + "type": "boolean", + "description": "Show SQL Console view automatically when an error has occurred.", + "default": true + }, "sqltools.results.reuseTabs": { "type": "string", "description": "How requests reuse results tabs.", diff --git a/packages/plugins/connection-manager/webview/results.ts b/packages/plugins/connection-manager/webview/results.ts index 1ce425a12..4af48404f 100644 --- a/packages/plugins/connection-manager/webview/results.ts +++ b/packages/plugins/connection-manager/webview/results.ts @@ -122,7 +122,7 @@ class ResultsWebview extends WebviewProvider { this.title = `${prefix}: ${suffix}`; } catch (error) { } this.updatePanelName(); - this.sendMessage(UIAction.RESPONSE_RESULTS, { resultTabs: payload, hasError: payload.some(p => !!p.error) }); + this.sendMessage(UIAction.RESPONSE_RESULTS, { resultTabs: payload, showConsole: Config.results.showConsoleOnError && payload.some(p => !!p.error) }); } whereToShow = vscode.ViewColumn.Active; diff --git a/packages/plugins/connection-manager/webview/ui/screens/Results/context/ResultsContext.tsx b/packages/plugins/connection-manager/webview/ui/screens/Results/context/ResultsContext.tsx index 43f9fe09f..714ad237c 100644 --- a/packages/plugins/connection-manager/webview/ui/screens/Results/context/ResultsContext.tsx +++ b/packages/plugins/connection-manager/webview/ui/screens/Results/context/ResultsContext.tsx @@ -50,10 +50,10 @@ export const ResultsProvider = ({ children }: IResultsProviderProps) => { }, []); useEffect(() => { - if (state.hasError) { + if (state.showConsole) { openMessagesConsole(); } - }, [state.hasError]); + }, [state.showConsole]); useEffect(() => { sendMessage(UIAction.REQUEST_SYNC_CONSOLE_MESSAGES, state.resultTabs[state.activeTab]?.messages ?? []); diff --git a/packages/plugins/connection-manager/webview/ui/screens/Results/context/reducer.ts b/packages/plugins/connection-manager/webview/ui/screens/Results/context/reducer.ts index 966b43689..0ba1ef5af 100644 --- a/packages/plugins/connection-manager/webview/ui/screens/Results/context/reducer.ts +++ b/packages/plugins/connection-manager/webview/ui/screens/Results/context/reducer.ts @@ -8,7 +8,7 @@ const log = createLogger('Results:reducer'); const initialState: ResultsScreenState = { loading: true, - hasError: false, + showConsole: false, resultTabs: [], activeTab: 0, }; diff --git a/packages/plugins/connection-manager/webview/ui/screens/Results/interfaces.ts b/packages/plugins/connection-manager/webview/ui/screens/Results/interfaces.ts index 6ff9e6383..6367d180f 100644 --- a/packages/plugins/connection-manager/webview/ui/screens/Results/interfaces.ts +++ b/packages/plugins/connection-manager/webview/ui/screens/Results/interfaces.ts @@ -10,7 +10,7 @@ export type ResultsReducerAction< export interface ResultsScreenState { loading: boolean; - hasError: boolean; + showConsole: boolean; resultTabs: NSDatabase.IResult[]; activeTab: number; } diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index 4f8c1720f..f6203d560 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -471,6 +471,14 @@ export interface IResultsOptions { */ limit: number; + /** + * Show SQL Console view automatically when an error has occurred + * @type {boolean} + * @default true + * @memberof IResultsOptions + */ + showConsoleOnError?: boolean; + /** * Defines how results tabs are or are not reused * @type {string}