Bug 90172

Summary: Web Inspector: Make the Tab character 4 spaces width
Product: WebKit Reporter: Nikita Vasilyev <me>
Component: Web Inspector (Deprecated)Assignee: Nikita Vasilyev <me>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, bweinstein, joepeck, keishi, loislo, pfeldman, pmuellr, rik, timothy, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Tab character width setting
none
WIP
none
Sublime Text 2 indent settings
none
Make the Tab character 4 spaces width none

Description Nikita Vasilyev 2012-06-28 06:41:45 PDT
Created attachment 149939 [details]
Tab character width setting

In source editor, tab character width is 8 characters long. Since WebKit supports tab-size CSS property (https://bugs.webkit.org/show_bug.cgi?id=52994), it would be nice to make tab character width configurable.
Comment 1 Pavel Feldman 2012-06-29 21:59:34 PDT
@Nikita, do you have a patch for this?
Comment 2 Nikita Vasilyev 2012-06-30 00:34:51 PDT
(In reply to comment #1)
> @Nikita, do you have a patch for this?

No, but I can make one if think it’s a valuable feature.
Comment 3 Pavel Feldman 2012-07-02 06:22:27 PDT
> No, but I can make one if think it’s a valuable feature.

I think it would be useful.
Comment 4 Nikita Vasilyev 2012-07-02 16:07:21 PDT
Created attachment 150494 [details]
WIP

I’m not sure about TextIndent class I introduced.
Comment 5 Pavel Feldman 2012-07-04 06:26:09 PDT
Comment on attachment 150494 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=150494&action=review

> Source/WebCore/inspector/front-end/SettingsScreen.js:282
> +    p.appendChild(this._createSelectSetting(WebInspector.UIString("Indent size"), [

Indentation size and tab size can have different values. Indentation size is a "model" property, it affects the file being saved on disk. Tab size is "view" property, it only affects visual representation. I'd suggest that you add a selector for the tab size and use it in the TextEditor.js only. The model part of the code should stay the same.

> Source/WebCore/inspector/front-end/TextEditorModel.js:493
> +function TextIndent()

I don't think you need this, but if you did, you would need to format it as:

/**
 * @constructor
 */
WebInspector.TextEditorModel.Indent = function()
{
}

...
Comment 6 Nikita Vasilyev 2012-07-04 07:13:27 PDT
Created attachment 150790 [details]
Sublime Text 2 indent settings

(In reply to comment #5)
> (From update of attachment 150494 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=150494&action=review
> 
> > Source/WebCore/inspector/front-end/SettingsScreen.js:282
> > +    p.appendChild(this._createSelectSetting(WebInspector.UIString("Indent size"), [
> 
> Indentation size and tab size can have different values. Indentation size is a "model" property, it affects the file being saved on disk. Tab size is "view" property, it only affects visual representation. I'd suggest that you add a selector for the tab size and use it in the TextEditor.js only. The model part of the code should stay the same.

Why would someone want a tab size different from an indentation size? I’ve attached a screenshot of indentation settings in Sublime Text 2; it doesn’t distinguish indentation size and tab size.
Comment 7 Pavel Feldman 2012-07-04 07:54:56 PDT
> Why would someone want a tab size different from an indentation size? I’ve attached a screenshot of indentation settings in Sublime Text 2; it doesn’t distinguish indentation size and tab size.

Well, all the other editors I know distinguish between the two and it makes sense to me. As I explained above, one is about model and another is about view. Imagine the code guidelines where indentation is done using 4 spaces, while tab character is still allowed and should be 8 characters long. Or indentation is two tabs.
Comment 8 Nikita Vasilyev 2012-07-05 07:57:34 PDT
(In reply to comment #7)
> > Why would someone want a tab size different from an indentation size? I’ve attached a screenshot of indentation settings in Sublime Text 2; it doesn’t distinguish indentation size and tab size.
> 
> Well, all the other editors I know distinguish between the two and it makes sense to me. As I explained above, one is about model and another is about view. Imagine the code guidelines where indentation is done using 4 spaces, while tab character is still allowed and should be 8 characters long. Or indentation is two tabs.

I see IDEs such as Xcode and IntelliJ IDEA do distinguish the two. Many lightweight code editors such as Chocolat.app and Textmate don’t.

Personally, I just want to make a tab character 4 spaces width. It’s a default tab width in all the editors I’ve mentioned above.
Comment 9 Nikita Vasilyev 2012-07-10 07:31:33 PDT
Created attachment 151459 [details]
Make the Tab character 4 spaces width

I suggest to make this small change for now. If someone actually want to configure the Tab size, we’ll see the bug filled.
Comment 10 WebKit Review Bot 2012-07-10 09:11:25 PDT
Comment on attachment 151459 [details]
Make the Tab character 4 spaces width

Clearing flags on attachment: 151459

Committed r122227: <http://trac.webkit.org/changeset/122227>
Comment 11 WebKit Review Bot 2012-07-10 09:11:30 PDT
All reviewed patches have been landed.  Closing bug.