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 indentation behavior #8552

Open
cesarmansur opened this issue Apr 25, 2020 · 11 comments
Open

Auto indentation behavior #8552

cesarmansur opened this issue Apr 25, 2020 · 11 comments
Labels
feature request xf:sql editor SQL Editor and Editor Services like autocompletion, highlighting, folding, formatting, etc. xf:sql

Comments

@cesarmansur
Copy link

Hello.
I'd like to have an option to disable auto indentation after inserting empty lines. This is the default behavior in Notepad++, for example. But I think it could be configurable in DBeaver.

@uslss
Copy link
Member

uslss commented Apr 27, 2020

hi @cesarmansur ,
probably default formatter changing could solve your problem? e.g. for Compact view
image

@cesarmansur
Copy link
Author

Hi @uslss
This is not exactly what I'm looking for...
I'm talking about the auto indentation feature, that automatically insert spaces in the new line, even if I remove the indentation and also after I enter empty new lines.
e.g.

Sample SQL
image

Now, if I press ENTER, the editor will automatically indent the new line. So far so good.
image

But, If I remove all the spaces from the new line and press ENTER, it will insist on putting spaces on the new lines. This is not desirable, as per I deliberately removed the spaces because I don't want them. It should follow the indentation from my previous empty line, that is none.
image

And even if I insert many empty lines, everytime I press ENTER it will insist in put spaces on my new line. This is very annoying.
image

My feature request is to have the automatic indentation disabled after the user inserted an empty and not indented new line. This is the default behavior on other editors. It should just follow the indentation from the previous line. If the previous line is empty and not indented, no indentation on the new line. Only if the previous line is indented, so make the editor auto indent the new line.
e.g. Notepad++
image

@uslss
Copy link
Member

uslss commented May 21, 2020

@cesarmansur thanks a lot for clarification and suggestion

@AndreSchulz-IONOS
Copy link

AndreSchulz-IONOS commented Jul 27, 2022

hi, any update here? having the same issue...

e.g. have a look at the following example:

SELECT col
    FROM tab;
-- test1
-- test2

if i want to add a new line before -- test2 i would put the cursor on the start of the line and hit enter.
this results in

SELECT col
    FROM tab;
-- test1

-- test2

so far so good.
but

SELECT col
    FROM tab
        WHERE a = 1;
-- test1
-- test2

results in

SELECT col
    FROM tab
        WHERE a = 1;
-- test1

    -- test2

@superclarkk
Copy link

Same issue. Any chance of a fix?

@MeboGit
Copy link

MeboGit commented Dec 8, 2022

Also having same issue, any fix or workaround?

@anymos
Copy link

anymos commented Dec 29, 2022

Same issue, looking forward for a fix ...

@w97655
Copy link

w97655 commented Oct 4, 2023

This forced indentation is so annoying. Incredible auto indent on/off is not available, it's such a small technical thing with a huge user impact.

@perbergstrand
Copy link

Ended up here when looking for how to disable the auto indenting. Apparently there is no such setting (odd since DBeaver has about a thousand settings :)). Please add this possibility. It is annoying to have to keep removing undesired added spaces when inserting a new line in the middle of a list or something else placed in the editor. Not all text placed there is pure SQL (for which I would still like to be able to get rid of the auto indenting), but meta text as well for the stuff you are working with at the moment.

@DreamXWay
Copy link

Did a quick search and the auto indent logic is most likely in SQLAutoIndentStrategy.java. Mark for myself to read the code later to see if it's possible to make a PR out of it.

As of the fixing approach, I don't think an extra preference option is needed, just follow the indent from the previous line, even if it is an empty line.

@mibrunet
Copy link

The problem with the auto indentation on new lines is that it aligns with the start position of the last line of code and adding empty lines in between does not change this behavior. Should adding an empty line reset the start position?

@LonwoLonwo LonwoLonwo added the xf:sql editor SQL Editor and Editor Services like autocompletion, highlighting, folding, formatting, etc. label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request xf:sql editor SQL Editor and Editor Services like autocompletion, highlighting, folding, formatting, etc. xf:sql
Projects
None yet
Development

No branches or pull requests