mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Ensure that SQL formatter should not add extra tabs and format the SQL correctly. Fixes #5869
2) Ensure that SQL formatter should not use tab size if 'Use spaces?' set to false. Fixes #6233
This commit is contained in:
@@ -46,6 +46,7 @@ def sql_format(sql):
|
||||
This function takes a SQL statement, formats it, and returns it
|
||||
"""
|
||||
p = Preferences.module('sqleditor')
|
||||
use_spaces = p.preference('use_spaces').get()
|
||||
output = sqlparse.format(sql,
|
||||
keyword_case=p.preference(
|
||||
'keyword_case').get(),
|
||||
@@ -63,10 +64,9 @@ def sql_format(sql):
|
||||
'comma_first').get(),
|
||||
wrap_after=p.preference(
|
||||
'wrap_after').get(),
|
||||
indent_tabs=not p.preference(
|
||||
'use_spaces').get(),
|
||||
indent_tabs=not use_spaces,
|
||||
indent_width=p.preference(
|
||||
'tab_size').get())
|
||||
'tab_size').get() if use_spaces else 1)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
@@ -225,8 +225,8 @@ function updateUIPreferences(sqlEditor) {
|
||||
}
|
||||
sqlEditor.query_tool_obj.setOption('foldGutter', preferences.code_folding);
|
||||
sqlEditor.query_tool_obj.setOption('indentWithTabs', !preferences.use_spaces);
|
||||
sqlEditor.query_tool_obj.setOption('indentUnit', preferences.tab_size);
|
||||
sqlEditor.query_tool_obj.setOption('tabSize', preferences.tab_size);
|
||||
sqlEditor.query_tool_obj.setOption('indentUnit', preferences.use_spaces ? preferences.tab_size : 4);
|
||||
sqlEditor.query_tool_obj.setOption('tabSize', preferences.use_spaces ? preferences.tab_size : 4);
|
||||
sqlEditor.query_tool_obj.setOption('lineWrapping', preferences.wrap_code);
|
||||
sqlEditor.query_tool_obj.setOption('autoCloseBrackets', preferences.insert_pair_brackets);
|
||||
sqlEditor.query_tool_obj.setOption('matchBrackets', preferences.brace_matching);
|
||||
|
||||
Reference in New Issue
Block a user