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

auto indent not working on new line after semicolon #2768

Closed
wthys opened this issue Jan 10, 2018 · 5 comments
Closed

auto indent not working on new line after semicolon #2768

wthys opened this issue Jan 10, 2018 · 5 comments

Comments

@wthys
Copy link

wthys commented Jan 10, 2018

I'm using DBeaver CE 4.3.2 on Ubuntu 16.04 and have noticed since 4.3.1 that when I start a new line in Oracle PL/SQL code the autoindent as in 4.2.x is only replicated when the previous line was not ended with a semicolon (';'). If the previous line was ended with a semicolon, the new line will start at column 1, not the at the previous indentation level.

There's no autoindent option in the GUI that I can find under preferences so I'm inclined to think this is a regression on previous behaviour

@wthys
Copy link
Author

wthys commented Jan 10, 2018

It seems it was a deliberate feature added in aedd8cd. Any chance in getting a config option to turn this on/off?

@serge-rider
Copy link
Member

Yes, this probably should be configurable.

@serge-rider
Copy link
Member

Or, better, we shouldn't reset indentation but we should do single "unindent" after semicolon. This makes sense for complicated query/procedures with multiple indentations.

@maffe
Copy link
Contributor

maffe commented Jul 5, 2018

Current behaviour is somewhat strange (or too simple) when editing PL/pgSQL:

DO $$
DECLARE
    a text[] := array['foo', 'bar'];
    t text;
BEGIN
    FOREACH t IN ARRAY a
    LOOP
        RAISE NOTICE '%', t;
    END LOOP;
END $$;

Instead of keeping the indentation of the previous line, the next line after pressing enter after a line ending with a semicolon starts one column too far to the left.

@michelvosje
Copy link
Contributor

It looks like that when a delimiter is detected at the end of the line where users starts the new line, the SQLIndenter always unindents the new line by 1 "column". It doesn't check whether the columns are build up by spaces or tabs.

So the following script will incorrectly unindent when adding a new line.
Assume that the '.' are spaces used as columns.

FOO
...BAR;_ // Add new line after the delimiter
BAZ
FOO
...BAR;
.._ // Now the new line is unindented by 1 column.
BAZ

When the line didn't end with a delimiter the SQLInderter will not unindent by 1 column.

The unindenting is caused by the following line.

michelvosje added a commit to michelvosje/dbeaver that referenced this issue Aug 26, 2018
michelvosje added a commit to michelvosje/dbeaver that referenced this issue Aug 26, 2018
serge-rider added a commit that referenced this issue Aug 26, 2018
#2768 Removed auto unindent on new line after delimiter.
@uslss uslss closed this as completed Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants