Bug #78245 Inconsistent indentation
Description:
The SQL Editor in MySQL Workbench has a nice auto indent feature that keeps the indentation you had in the last line when you press enter, however there is a problem with this feature.
The auto-indent feature in the editor indents using spaces, however when you press TAB MySQL Workbench inserts a TAB character, not spaces, causing the indentation to be inconsistent in your SQL Files.
How to repeat:
Create a new SQL Script tab.
Insert some text, for example:
CREATE TABLE Product(
Press enter on your keyboard. in the next line hit TAB to indent the code, then type more text, for example:
product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Press enter again. MySQL Workbench will keep your indentation level by inserting four spaces, then insert more text like:
name VARCHAR(100)
This produces this effect:
CREATE TABLE Product(
product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100)
(You can't see the difference in the SQL Editor but you will see it in other editors like Sublime Text or in version control diff tools)
Suggested fix:
There are two possible fixes for this:
One is to make the auto-indent feature use tabs, the other is change the SQL Editor so that it inserts soft tabs (four spaces) when you hit the TAB key.
Another, better yet solution is to allow the user to customize this feature, like most editors and IDEs do.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The SQL Editor in MySQL Workbench has a nice auto indent feature that keeps the indentation you had in the last line when you press enter, however there is a problem with this feature. The auto-indent feature in the editor indents using spaces, however when you press TAB MySQL Workbench inserts a TAB character, not spaces, causing the indentation to be inconsistent in your SQL Files. How to repeat: Create a new SQL Script tab. Insert some text, for example: CREATE TABLE Product( Press enter on your keyboard. in the next line hit TAB to indent the code, then type more text, for example: product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Press enter again. MySQL Workbench will keep your indentation level by inserting four spaces, then insert more text like: name VARCHAR(100) This produces this effect: CREATE TABLE Product( product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100) (You can't see the difference in the SQL Editor but you will see it in other editors like Sublime Text or in version control diff tools) Suggested fix: There are two possible fixes for this: One is to make the auto-indent feature use tabs, the other is change the SQL Editor so that it inserts soft tabs (four spaces) when you hit the TAB key. Another, better yet solution is to allow the user to customize this feature, like most editors and IDEs do.