Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sqltools.results.showConsoleOnError setting #1366

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`;
gjsjohnmurray marked this conversation as resolved.
Show resolved Hide resolved
} 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
Loading