mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure auto-indent honours the spaces/tabs config setting. Fixes #2780
This commit is contained in:
parent
ce5f5015b3
commit
0cb57848f8
@ -555,6 +555,9 @@ def utils():
|
|||||||
insert_pair_brackets_perf = prefs.preference('insert_pair_brackets')
|
insert_pair_brackets_perf = prefs.preference('insert_pair_brackets')
|
||||||
insert_pair_brackets = insert_pair_brackets_perf.get()
|
insert_pair_brackets = insert_pair_brackets_perf.get()
|
||||||
|
|
||||||
|
# This will be opposite of use_space option
|
||||||
|
editor_indent_with_tabs = False if editor_use_spaces else True
|
||||||
|
|
||||||
# Try to fetch current libpq version from the driver
|
# Try to fetch current libpq version from the driver
|
||||||
try:
|
try:
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
@ -578,6 +581,7 @@ def utils():
|
|||||||
editor_wrap_code=editor_wrap_code,
|
editor_wrap_code=editor_wrap_code,
|
||||||
editor_brace_matching=brace_matching,
|
editor_brace_matching=brace_matching,
|
||||||
editor_insert_pair_brackets=insert_pair_brackets,
|
editor_insert_pair_brackets=insert_pair_brackets,
|
||||||
|
editor_indent_with_tabs=editor_indent_with_tabs,
|
||||||
app_name=config.APP_NAME,
|
app_name=config.APP_NAME,
|
||||||
pg_libpq_version=pg_libpq_version
|
pg_libpq_version=pg_libpq_version
|
||||||
),
|
),
|
||||||
|
@ -1970,7 +1970,8 @@ define(
|
|||||||
tabSize: pgBrowser.utils.tabSize,
|
tabSize: pgBrowser.utils.tabSize,
|
||||||
wrapCode: pgBrowser.utils.wrapCode,
|
wrapCode: pgBrowser.utils.wrapCode,
|
||||||
insert_pair_brackets: pgBrowser.utils.insertPairBrackets,
|
insert_pair_brackets: pgBrowser.utils.insertPairBrackets,
|
||||||
brace_matching: pgBrowser.utils.braceMatching
|
brace_matching: pgBrowser.utils.braceMatching,
|
||||||
|
indent_with_tabs: pgBrowser.utils.is_indent_with_tabs
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,7 @@ define('pgadmin.browser.utils',
|
|||||||
useSpaces: '{{ editor_use_spaces }}',
|
useSpaces: '{{ editor_use_spaces }}',
|
||||||
insertPairBrackets: '{{ editor_insert_pair_brackets }}' == 'True',
|
insertPairBrackets: '{{ editor_insert_pair_brackets }}' == 'True',
|
||||||
braceMatching: '{{ editor_brace_matching }}' == 'True',
|
braceMatching: '{{ editor_brace_matching }}' == 'True',
|
||||||
|
is_indent_with_tabs: '{{ editor_indent_with_tabs }}' == 'True',
|
||||||
app_name: '{{ app_name }}',
|
app_name: '{{ app_name }}',
|
||||||
pg_libpq_version: {{pg_libpq_version|e}},
|
pg_libpq_version: {{pg_libpq_version|e}},
|
||||||
|
|
||||||
|
@ -2049,6 +2049,8 @@
|
|||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
mode: "text/x-pgsql",
|
mode: "text/x-pgsql",
|
||||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||||
|
indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
|
||||||
|
indentUnit: pgAdmin.Browser.editor_options.tabSize,
|
||||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
||||||
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
||||||
|
@ -258,9 +258,10 @@ define('pgadmin.datagrid', [
|
|||||||
// Apply CodeMirror to filter text area.
|
// Apply CodeMirror to filter text area.
|
||||||
this.filter_obj = CodeMirror.fromTextArea($sql_filter.get(0), {
|
this.filter_obj = CodeMirror.fromTextArea($sql_filter.get(0), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
indentUnit: 4,
|
|
||||||
mode: "text/x-pgsql",
|
mode: "text/x-pgsql",
|
||||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||||
|
indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
|
||||||
|
indentUnit: pgAdmin.Browser.editor_options.tabSize,
|
||||||
tabSize: pgBrowser.editor_options.tabSize,
|
tabSize: pgBrowser.editor_options.tabSize,
|
||||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
||||||
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
||||||
|
@ -1636,6 +1636,8 @@ define([
|
|||||||
mode: "text/x-pgsql",
|
mode: "text/x-pgsql",
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||||
|
indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
|
||||||
|
indentUnit: pgAdmin.Browser.editor_options.tabSize,
|
||||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
||||||
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
||||||
|
@ -117,9 +117,13 @@ class SqlEditorModule(PgAdminModule):
|
|||||||
category_label=gettext('Display'),
|
category_label=gettext('Display'),
|
||||||
min_val=-1,
|
min_val=-1,
|
||||||
max_val=999999,
|
max_val=999999,
|
||||||
help_str=gettext('The length of time to display the query info notifier after execution has completed. '
|
help_str=gettext(
|
||||||
'A value of -1 disables the notifier and a value of 0 displays it until clicked. '
|
'The length of time to display the query info notifier after '
|
||||||
'Values greater than 1 display the notifier for the number of seconds specified.')
|
'execution has completed. A value of -1 disables the notifier '
|
||||||
|
'and a value of 0 displays it until clicked. Values greater '
|
||||||
|
'than 1 display the notifier for the number of seconds '
|
||||||
|
'specified.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.open_in_new_tab = self.preference.register(
|
self.open_in_new_tab = self.preference.register(
|
||||||
@ -172,10 +176,13 @@ class SqlEditorModule(PgAdminModule):
|
|||||||
min_val=0.1,
|
min_val=0.1,
|
||||||
max_val=10,
|
max_val=10,
|
||||||
category_label=gettext('Display'),
|
category_label=gettext('Display'),
|
||||||
help_str=gettext('The font size to use for the SQL text boxes and editors. '
|
help_str=gettext(
|
||||||
'The value specified is in "em" units, in which 1 is the default relative font size. '
|
'The font size to use for the SQL text boxes and editors. '
|
||||||
'For example, to increase the font size by 20 percent use a value of 1.2, or to reduce '
|
'The value specified is in "em" units, in which 1 is the '
|
||||||
'by 20 percent, use a value of 0.8. Minimum 0.1, maximum 10.')
|
'default relative font size. For example, to increase the '
|
||||||
|
'font size by 20 percent use a value of 1.2, or to reduce '
|
||||||
|
'by 20 percent, use a value of 0.8. Minimum 0.1, maximum 10.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.tab_size = self.preference.register(
|
self.tab_size = self.preference.register(
|
||||||
@ -184,35 +191,48 @@ class SqlEditorModule(PgAdminModule):
|
|||||||
min_val=2,
|
min_val=2,
|
||||||
max_val=8,
|
max_val=8,
|
||||||
category_label=gettext('Options'),
|
category_label=gettext('Options'),
|
||||||
help_str=gettext('The number of spaces per tab. Minimum 2, maximum 8.')
|
help_str=gettext(
|
||||||
|
'The number of spaces per tab. Minimum 2, maximum 8.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.use_spaces = self.preference.register(
|
self.use_spaces = self.preference.register(
|
||||||
'Options', 'use_spaces',
|
'Options', 'use_spaces',
|
||||||
gettext("Use spaces?"), 'boolean', False,
|
gettext("Use spaces?"), 'boolean', False,
|
||||||
category_label=gettext('Options'),
|
category_label=gettext('Options'),
|
||||||
help_str=gettext('Specifies whether or not to insert spaces instead of tabs when the tab key is used.')
|
help_str=gettext(
|
||||||
|
'Specifies whether or not to insert spaces instead of tabs '
|
||||||
|
'when the tab key or auto-indent are used.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.wrap_code = self.preference.register(
|
self.wrap_code = self.preference.register(
|
||||||
'Options', 'wrap_code',
|
'Options', 'wrap_code',
|
||||||
gettext("Line wrapping?"), 'boolean', False,
|
gettext("Line wrapping?"), 'boolean', False,
|
||||||
category_label=gettext('Options'),
|
category_label=gettext('Options'),
|
||||||
help_str=gettext('Specifies whether or not to wrap SQL code in the editor.')
|
help_str=gettext(
|
||||||
|
'Specifies whether or not to wrap SQL code in the editor.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.insert_pair_brackets = self.preference.register(
|
self.insert_pair_brackets = self.preference.register(
|
||||||
'Options', 'insert_pair_brackets',
|
'Options', 'insert_pair_brackets',
|
||||||
gettext("Insert bracket pairs?"), 'boolean', True,
|
gettext("Insert bracket pairs?"), 'boolean', True,
|
||||||
category_label=gettext('Options'),
|
category_label=gettext('Options'),
|
||||||
help_str=gettext('Specifies whether or not to insert paired brackets in the editor.')
|
help_str=gettext(
|
||||||
|
'Specifies whether or not to insert paired brackets in the '
|
||||||
|
'editor.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.brace_matching = self.preference.register(
|
self.brace_matching = self.preference.register(
|
||||||
'Options', 'brace_matching',
|
'Options', 'brace_matching',
|
||||||
gettext("Brace matching?"), 'boolean', True,
|
gettext("Brace matching?"), 'boolean', True,
|
||||||
category_label=gettext('Options'),
|
category_label=gettext('Options'),
|
||||||
help_str=gettext('Specifies whether or not to highlight matched braces in the editor.')
|
help_str=gettext(
|
||||||
|
'Specifies whether or not to highlight matched braces '
|
||||||
|
'in the editor.'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -222,7 +242,9 @@ blueprint = SqlEditorModule(MODULE_NAME, __name__, static_url_path='/static')
|
|||||||
@blueprint.route('/')
|
@blueprint.route('/')
|
||||||
@login_required
|
@login_required
|
||||||
def index():
|
def index():
|
||||||
return bad_request(errormsg=gettext('This URL cannot be requested directly.'))
|
return bad_request(
|
||||||
|
errormsg=gettext('This URL cannot be requested directly.')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_session_grid_transaction(trans_id, data):
|
def update_session_grid_transaction(trans_id, data):
|
||||||
@ -248,7 +270,9 @@ def check_transaction_status(trans_id):
|
|||||||
|
|
||||||
# Return from the function if transaction id not found
|
# Return from the function if transaction id not found
|
||||||
if str(trans_id) not in grid_data:
|
if str(trans_id) not in grid_data:
|
||||||
return False, gettext('Transaction ID not found in the session.'), None, None, None
|
return False, gettext(
|
||||||
|
'Transaction ID not found in the session.'
|
||||||
|
), None, None, None
|
||||||
|
|
||||||
# Fetch the object for the specified transaction id.
|
# Fetch the object for the specified transaction id.
|
||||||
# Use pickle.loads function to get the command object
|
# Use pickle.loads function to get the command object
|
||||||
|
@ -109,7 +109,6 @@ define('tools.querytool', [
|
|||||||
$('.editor-title').text(_.unescape(self.editor_title));
|
$('.editor-title').text(_.unescape(self.editor_title));
|
||||||
self.filter_obj = CodeMirror.fromTextArea(filter.get(0), {
|
self.filter_obj = CodeMirror.fromTextArea(filter.get(0), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
indentUnit: 4,
|
|
||||||
mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
|
mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
|
||||||
foldOptions: {
|
foldOptions: {
|
||||||
widget: "\u2026"
|
widget: "\u2026"
|
||||||
@ -120,6 +119,8 @@ define('tools.querytool', [
|
|||||||
},
|
},
|
||||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||||
|
indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
|
||||||
|
indentUnit: pgAdmin.Browser.editor_options.tabSize,
|
||||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
||||||
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
|
||||||
@ -153,7 +154,6 @@ define('tools.querytool', [
|
|||||||
|
|
||||||
self.query_tool_obj = CodeMirror.fromTextArea(text_container.get(0), {
|
self.query_tool_obj = CodeMirror.fromTextArea(text_container.get(0), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
indentUnit: 4,
|
|
||||||
styleSelectedText: true,
|
styleSelectedText: true,
|
||||||
mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
|
mode: self.handler.server_type === "gpdb" ? "text/x-gpsql" : "text/x-pgsql",
|
||||||
foldOptions: {
|
foldOptions: {
|
||||||
@ -165,6 +165,8 @@ define('tools.querytool', [
|
|||||||
},
|
},
|
||||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||||
extraKeys: pgBrowser.editor_shortcut_keys,
|
extraKeys: pgBrowser.editor_shortcut_keys,
|
||||||
|
indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
|
||||||
|
indentUnit: pgAdmin.Browser.editor_options.tabSize,
|
||||||
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
tabSize: pgAdmin.Browser.editor_options.tabSize,
|
||||||
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
|
||||||
scrollbarStyle: 'simple',
|
scrollbarStyle: 'simple',
|
||||||
|
Loading…
Reference in New Issue
Block a user