Skip to content

Commit da53082

Browse files
Fixed an issue where indent with space was not aligning to next tab position. #7486
1 parent ea69339 commit da53082

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/en_US/release_notes_8_14.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ New features
2121
************
2222

2323
| `Issue #5786 <https://github.com/pgadmin-org/pgadmin4/issues/5786>`_ - Allow the use of a pgpass file in the pgAdmin container via Docker secrets.
24+
| `Issue #6592 <https://github.com/pgadmin-org/pgadmin4/issues/6592>`_ - Fixed multiple issues and improved ERD auto-layout.
2425
| `Issue #8095 <https://github.com/pgadmin-org/pgadmin4/issues/8095>`_ - Added support for a builtin locale provider in the Database dialog.
2526
2627
Housekeeping
@@ -32,6 +33,7 @@ Bug fixes
3233

3334
| `Issue #5099 <https://github.com/pgadmin-org/pgadmin4/issues/5099>`_ - Fixed an issue where Ctrl/Cmd + A was not selecting all data in query tool data grid.
3435
| `Issue #7384 <https://github.com/pgadmin-org/pgadmin4/issues/7384>`_ - Fixed an issue where querying a foreign table gives the error 'ForeignTableCommand' object has no attribute 'auto_commit'.
36+
| `Issue #7486 <https://github.com/pgadmin-org/pgadmin4/issues/7486>`_ - Fixed an issue where indent with space was not aligning to next tab position.
3537
| `Issue #7865 <https://github.com/pgadmin-org/pgadmin4/issues/7865>`_ - Fixed an issue related to the query tool update connection after the server disconnected from the object explorer.
3638
| `Issue #8010 <https://github.com/pgadmin-org/pgadmin4/issues/8010>`_ - Fixed an issue where query tool should show results and messages only from the last executed query.
3739
| `Issue #8065 <https://github.com/pgadmin-org/pgadmin4/issues/8065>`_ - Ensure the crypt key is retrieved correctly on backend server restart.

web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ function handlePaste(e) {
104104
function insertTabWithUnit({ state, dispatch }) {
105105
if (state.selection.ranges.some(r => !r.empty))
106106
return indentMore({ state, dispatch });
107-
dispatch(state.update(state.replaceSelection(state.facet(indentUnit)), { scrollIntoView: true, userEvent: 'input' }));
107+
108+
// If indent is space based, then calc the number of spaces required.
109+
let indentVal = state.facet(indentUnit);
110+
if(indentVal != '\t') {
111+
const line = state.doc.lineAt(state.selection.main.head);
112+
indentVal = ' '.repeat(indentVal.length - (state.selection.main.head - line.from) % indentVal.length);
113+
}
114+
dispatch(state.update(state.replaceSelection(indentVal), { scrollIntoView: true, userEvent: 'input' }));
108115
return true;
109116
}
110117

@@ -181,7 +188,7 @@ export default function Editor({
181188
useEffect(() => {
182189
if (!checkIsMounted()) return;
183190
const finalOptions = { ...defaultOptions, ...options };
184-
const osEOL = OS_EOL === 'crlf' ? '\r\n' : '\n';
191+
const osEOL = OS_EOL === 'crlf' ? '\r\n' : '\n';
185192
const finalExtns = [
186193
(language == 'json') ? json() : sql({dialect: PgSQL}),
187194
...defaultExtensions,

0 commit comments

Comments
 (0)