Add support for highlighting selection matches in the query editor. #7530

This commit is contained in:
Rohit Bhati 2024-07-18 17:51:20 +05:30 committed by GitHub
parent fd78faf0cc
commit 8030bc708b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 1 deletions

View File

@ -400,6 +400,9 @@ Use the fields on the *Editor* panel to change settings of the query editor.
changed to text/plain. Keyword highlighting and code folding will be disabled. changed to text/plain. Keyword highlighting and code folding will be disabled.
This will improve editor performance with large files. This will improve editor performance with large files.
* When the *Highlight selection matches?* switch is set to *True*, the editor will
highlight matched selected text.
.. image:: images/preferences_sql_explain.png .. image:: images/preferences_sql_explain.png
:alt: Preferences dialog sqleditor explain options :alt: Preferences dialog sqleditor explain options
:align: center :align: center

View File

@ -490,6 +490,11 @@ def utils():
brace_matching_pref = prefs.preference('brace_matching') brace_matching_pref = prefs.preference('brace_matching')
brace_matching = brace_matching_pref.get() brace_matching = brace_matching_pref.get()
highlight_selection_matches_pref = prefs.preference(
'highlight_selection_matches'
)
highlight_selection_matches = highlight_selection_matches_pref.get()
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()
@ -542,6 +547,7 @@ def utils():
editor_use_spaces=editor_use_spaces, editor_use_spaces=editor_use_spaces,
editor_wrap_code=editor_wrap_code, editor_wrap_code=editor_wrap_code,
editor_brace_matching=brace_matching, editor_brace_matching=brace_matching,
editor_highlight_selection_matches=highlight_selection_matches,
editor_insert_pair_brackets=insert_pair_brackets, editor_insert_pair_brackets=insert_pair_brackets,
editor_indent_with_tabs=editor_indent_with_tabs, editor_indent_with_tabs=editor_indent_with_tabs,
app_name=config.APP_NAME, app_name=config.APP_NAME,

View File

@ -1728,6 +1728,7 @@ define('pgadmin.browser', [
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, indent_with_tabs: pgBrowser.utils.is_indent_with_tabs,
highlightSelectionMatches:pgBrowser.utils.highlightSelectionMatches
}, },
}); });

View File

@ -93,6 +93,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',
highlightSelectionMatches: '{{editor_highlight_selection_matches}}' == 'True',
is_indent_with_tabs: '{{ editor_indent_with_tabs }}' == 'True', is_indent_with_tabs: '{{ editor_indent_with_tabs }}' == 'True',
app_name: '{{ app_name }}', app_name: '{{ app_name }}',
app_version_int: '{{ app_version_int}}', app_version_int: '{{ app_version_int}}',

View File

@ -38,7 +38,7 @@ import {
foldKeymap, foldKeymap,
indentService indentService
} from '@codemirror/language'; } from '@codemirror/language';
import { highlightSelectionMatches } from '@codemirror/search';
import syntaxHighlighting from '../extensions/highlighting'; import syntaxHighlighting from '../extensions/highlighting';
import PgSQL from '../extensions/dialect'; import PgSQL from '../extensions/dialect';
import { sql } from '@codemirror/lang-sql'; import { sql } from '@codemirror/lang-sql';
@ -343,6 +343,11 @@ export default function Editor({
if (pref.insert_pair_brackets) { if (pref.insert_pair_brackets) {
newConfigExtn.push(closeBrackets()); newConfigExtn.push(closeBrackets());
} }
if (pref.highlight_selection_matches){
newConfigExtn.push(highlightSelectionMatches());
}
if (pref.brace_matching) { if (pref.brace_matching) {
newConfigExtn.push(bracketMatching()); newConfigExtn.push(bracketMatching());
} }

View File

@ -208,6 +208,16 @@ def register_query_tool_preferences(self):
) )
) )
self.highlight_selection_matches = self.preference.register(
'Editor', 'highlight_selection_matches',
gettext("Highlight selection matches?"), 'boolean', True,
category_label=PREF_LABEL_OPTIONS,
help_str=gettext(
'Specifies whether or not to highlight matched selected text '
'in the editor.'
)
)
self.brace_matching = self.preference.register( self.brace_matching = self.preference.register(
'Editor', 'brace_matching', 'Editor', 'brace_matching',
gettext("Brace matching?"), 'boolean', True, gettext("Brace matching?"), 'boolean', True,