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-capitalizing keywords like SELECT, FROM, etc. #337

Closed
halmai opened this Issue Aug 31, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@halmai

halmai commented Aug 31, 2018

Steps to reproduce this issue

  1. Step 1; I start to type "select * from my_table where id = 1;" in the query editor.

Current behavior

I can see exactly what I typed:
"select * from my_table where id = 1;"

Expected behavior

I would like to see capitalised keywords:
"SELECT * FROM my_table WHERE id = 1;"

Possible solution

Under Tools -> Preferences -> SQL, where I can set the colors and other attributes the of individual content categories, I would like to have a checkbox "[X] Capitalized". I would love to turn it on for Reserver Words.

Environment

Version 9.5.0.5277 (64 Bit)
Compiled on: 2018-04-19 05:52:03
Environment: Windows v6.1

@ansgarbecker

This comment has been minimized.

Show comment
Hide comment
@ansgarbecker

ansgarbecker Aug 31, 2018

Collaborator

That is what the "Auto reformat" feature is meant for.
Just click the button on the main toolbar with the white page and a paintbrush on it.

Collaborator

ansgarbecker commented Aug 31, 2018

That is what the "Auto reformat" feature is meant for.
Just click the button on the main toolbar with the white page and a paintbrush on it.

@halmai

This comment has been minimized.

Show comment
Hide comment
@halmai

halmai Aug 31, 2018

Thanks for the quick asnwer. :)

I don't think they are the same.

  1. My proposal would capitalise "select" right after pressing the last character ("t") while the toolbar button requires deliberate activity from my side

  2. The toolbar changes the indentation as well which I would hate. I know why I indented my query in the way how I did and I don't want any software to re-indent it, unless I explicitely ask for it.

halmai commented Aug 31, 2018

Thanks for the quick asnwer. :)

I don't think they are the same.

  1. My proposal would capitalise "select" right after pressing the last character ("t") while the toolbar button requires deliberate activity from my side

  2. The toolbar changes the indentation as well which I would hate. I know why I indented my query in the way how I did and I don't want any software to re-indent it, unless I explicitely ask for it.

@ansgarbecker

This comment has been minimized.

Show comment
Hide comment
@ansgarbecker

ansgarbecker Aug 31, 2018

Collaborator

Yes, I noticed your wish is different, only I don't want to implement similar things two times.

There is a second way to accomplish that: start typing "sel", press Ctrl+Space, which should offer the completion proposal with the SELECT keyword, then press Enter to overtake it.

Collaborator

ansgarbecker commented Aug 31, 2018

Yes, I noticed your wish is different, only I don't want to implement similar things two times.

There is a second way to accomplish that: start typing "sel", press Ctrl+Space, which should offer the completion proposal with the SELECT keyword, then press Enter to overtake it.

@halmai

This comment has been minimized.

Show comment
Hide comment
@halmai

halmai Sep 1, 2018

I understand this but I still think it would be a very useful feature because Ctrl+Space is much less convenient.

For example, when I type "from" then Ctrl+Space offers three options:

  • FROM_DAYS(N)
  • FROM_UNIXTIME
  • FROM
    So, after "from", I still need 4 key presses (Ctrl+Space, Cursor Down, Cursor Down and Enter) or 3 if I am a power user (and I know Cursor Up replaces the two Cursor Downs) to capitalise it. By contrast, an auto-capitalize function would capitalise "FROM" automatically, right after I finish the word.

Unfortunately I cannot use Heidi at my workplace and I have to use SequelPro for Mac which does this autoformat thing. I don't reallt like SequelPro but this is a feature of it I really love and would love it in Heidi as well.

UPDATE: just one more tought. There are three different things but they have different purposes as well:

  • syntax highlighting/capitalizing: leaves every character at their position, just changes their appearance
  • autoformat: re-indents the code but does not change the meaning of the query
  • suggestions (Ctrl+Space): it actually changes the query, it builds it.

So, my suggestion would not implement the same functionality that we have somewhere else. It is a new feature.

halmai commented Sep 1, 2018

I understand this but I still think it would be a very useful feature because Ctrl+Space is much less convenient.

For example, when I type "from" then Ctrl+Space offers three options:

  • FROM_DAYS(N)
  • FROM_UNIXTIME
  • FROM
    So, after "from", I still need 4 key presses (Ctrl+Space, Cursor Down, Cursor Down and Enter) or 3 if I am a power user (and I know Cursor Up replaces the two Cursor Downs) to capitalise it. By contrast, an auto-capitalize function would capitalise "FROM" automatically, right after I finish the word.

Unfortunately I cannot use Heidi at my workplace and I have to use SequelPro for Mac which does this autoformat thing. I don't reallt like SequelPro but this is a feature of it I really love and would love it in Heidi as well.

UPDATE: just one more tought. There are three different things but they have different purposes as well:

  • syntax highlighting/capitalizing: leaves every character at their position, just changes their appearance
  • autoformat: re-indents the code but does not change the meaning of the query
  • suggestions (Ctrl+Space): it actually changes the query, it builds it.

So, my suggestion would not implement the same functionality that we have somewhere else. It is a new feature.

@ansgarbecker

This comment has been minimized.

Show comment
Hide comment
@ansgarbecker

ansgarbecker Sep 2, 2018

Collaborator

Makes sense now!

Collaborator

ansgarbecker commented Sep 2, 2018

Makes sense now!

@ansgarbecker

This comment has been minimized.

Show comment
Hide comment
@ansgarbecker

ansgarbecker Sep 2, 2018

Collaborator

I have just pushed some code extension which now by default transforms the previous reserved word, data type or function to uppercase. Users can disable this feature, in Preferences > SQL > "Auto uppercase..."

Please update and test.

Collaborator

ansgarbecker commented Sep 2, 2018

I have just pushed some code extension which now by default transforms the previous reserved word, data type or function to uppercase. Users can disable this feature, in Preferences > SQL > "Auto uppercase..."

Please update and test.

@ansgarbecker ansgarbecker added this to the v9.6 milestone Sep 2, 2018

ansgarbecker added a commit that referenced this issue Sep 2, 2018

Follow up to previous commit, #337: fix various bugs with selected te…
…xt, and detect an identifier also after a line break
@ansgarbecker

This comment has been minimized.

Show comment
Hide comment
@ansgarbecker

ansgarbecker Sep 2, 2018

Collaborator

Already found some bugs, which should be fixed in the upcoming Heidi build. Please retest if not done already.

Collaborator

ansgarbecker commented Sep 2, 2018

Already found some bugs, which should be fixed in the upcoming Heidi build. Please retest if not done already.

@halmai

This comment has been minimized.

Show comment
Hide comment
@halmai

halmai Sep 3, 2018

Oh, great news, thank. :)

I installed Version 9.5.0.5293 (64 Bit) and works nice. Thanks. :)

However, it is not exactly what I asked for. I thought you implement it more similarly to the syntax highlighting. I expected a checkbox where the Bold and the Itcalic checkboxes are. That implementation whould make it possible for the user to capitalize/not capitalize function names, keywords, tablenames, independently from each other. I think it would be more felixible.

There is one more think. It is a bit strange that I type "select" and right after "t" the color is changing but the capitalization happens only one character later, when the space also is pressed. Is this indented? Why does it indicate to be a keyword by color change earlier than it indicates the same thing by capitalizing?

halmai commented Sep 3, 2018

Oh, great news, thank. :)

I installed Version 9.5.0.5293 (64 Bit) and works nice. Thanks. :)

However, it is not exactly what I asked for. I thought you implement it more similarly to the syntax highlighting. I expected a checkbox where the Bold and the Itcalic checkboxes are. That implementation whould make it possible for the user to capitalize/not capitalize function names, keywords, tablenames, independently from each other. I think it would be more felixible.

There is one more think. It is a bit strange that I type "select" and right after "t" the color is changing but the capitalization happens only one character later, when the space also is pressed. Is this indented? Why does it indicate to be a keyword by color change earlier than it indicates the same thing by capitalizing?

@cookieguru

This comment has been minimized.

Show comment
Hide comment
@cookieguru

cookieguru Sep 3, 2018

I would like to request a little bit more intelligence too

Typing

select t.name from mytable t

produces

SELECT t.NAME FROM mytable t

But I expect

SELECT t.name FROM mytable t

Essentially, coulmn names can be reserved words but shouldn't be automatically capaitalized.

cookieguru commented Sep 3, 2018

I would like to request a little bit more intelligence too

Typing

select t.name from mytable t

produces

SELECT t.NAME FROM mytable t

But I expect

SELECT t.name FROM mytable t

Essentially, coulmn names can be reserved words but shouldn't be automatically capaitalized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment