Skip to content

Commit

Permalink
Add sqltools.results.showConsoleOnError setting (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray authored Aug 28, 2024
1 parent 9e2734f commit 5dc708f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/connection-manager/webview/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ResultsWebview extends WebviewProvider<ResultsScreenState> {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const log = createLogger('Results:reducer');

const initialState: ResultsScreenState = {
loading: true,
hasError: false,
showConsole: false,
resultTabs: [],
activeTab: 0,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ResultsReducerAction<

export interface ResultsScreenState {
loading: boolean;
hasError: boolean;
showConsole: boolean;
resultTabs: NSDatabase.IResult[];
activeTab: number;
}
8 changes: 8 additions & 0 deletions packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 5dc708f

Please sign in to comment.