22

Spaces, no tabs

I was attempting to clean up a question (https://stackoverflow.com/revisions/44221809/1) and the SO editor on my Mac (macOS Sierra 10.12.5, Firefox 53.0.3) had conniptions.

It seemed that the gaps between words were tabs, not spaces. As I was fixing tabs to spaces, the display would sometimes run words together, but when I inserted a space, it would behave as if there was a tab between the words after all.

I ended up copying and pasting the formatted text into the question, and then reformatting that. This eliminated the tabs.

(The question I was editing isn't very good, but if anyone else manages to get the same editing experience on it, then there's something that should be fixed in the SO editor. If no-one else can simulate it — I'm not sure if it'll require rollbacks to get to the original material to try editing it again — then I'll quietly delete this.)

Just for kicks, below the horizontal rule is a copy of most of this question with the blanks replaced by tabs. When I edit it, it shows the same eccentric behaviour, so either my browser is confused or there does seem to be a problem.

Image

Image obtained while editing 'Tabs instead of spaces'


Tabs instead of spaces

I was attempting to clean up a question (https://stackoverflow.com/revisions/44221809/1) and the SO editor on my Mac (macOS Sierra 10.12.5, Firefox 53.0.3) had conniptions.

It seemed that the gaps between words were tabs, not spaces. As I was fixing tabs to spaces, the display would sometimes run words together, but when I inserted a space, it would behave as if there was a tab between the words after all.

I ended up copying and pasting the formatted text into the question, and then reformatting that. This eliminated the tabs.

(The question I was editing isn't very good, but if anyone else manages to get the same editing experience on it, then there's something that should be fixed in the SO editor. If no-one else can simulate it — I'm not sure if it'll require rollbacks to get to the original material to try editing it again — then I'll quietly delete this.)

Just for kicks, below the horizontal rule is a copy of most of this question with the blanks replaced by tabs. When I edit it, it shows the same eccentric behaviour, so either my browser is confused or there does seem to be a problem.

11
  • 1
    Note that the display of the text with tabs is fine — it is the experience while using the SO editor that is confusing. Commented May 27, 2017 at 21:58
  • I've restarted my Firefox and tried editing this question (but cancelled the edit), and I still got the odd behaviour. I'm willing to accept it is still an issue with my machine/browser combination. I have tried Chrome (58.0.3029.110) on it; it seems to show 'ordinary tab-like behaviour' — the words are aligned so they start in column numbers of the form 4N+1. I'll post images (sans red circles) if people want to see what I see. Commented May 28, 2017 at 7:45
  • 1
    Way to make me do a double-take. Commented May 28, 2017 at 22:22
  • I don't think I'm able to reproduce your issue (Firefox 45.8.0 on Debian), neither here on on the original post. Changing tabs to spaces seems to work as expected, no weirdness in the preview or the editor. FWIW, one (with >10k rep) can edit the first revision directly in the edit history of the post. Commented May 28, 2017 at 22:29
  • @AndrasDeak: Thanks for the extra information. I've not spotted the problem before, so it could be a new issue afflicting Firefox 53, or it could be Mac + Firefox specific. But every data point like that may help the 'team' identify where the problem is. Commented May 28, 2017 at 22:50
  • 1
    @AndrasDeak actually, you can force the non-inline editor and you can select which revision you would want.
    – Braiam
    Commented May 28, 2017 at 23:24
  • @Braiam ah, right! I keep seeing that drop-down in the editor and yet I always forget that it exists. Anyway, my point was that rollbacks are probably unnecessary to test this issue on the original post. Commented May 28, 2017 at 23:26
  • 1
    Using Firefox 53.0.3 on Windows 10, I don't have this issue. Commented May 29, 2017 at 12:17
  • 2
    I think I finally understand what you experienced. It's as if the tabs were allowed to occupy zero width while still being there (much like a pair of ill-placed tabs in MS word), essentially acting as a zero-width space. When you added an additional vanilla space there, the tab expanded too, revealing itself. In this case you could've instead selected the zero-width tab with shift+arrow, and replaced it with a space, and would've seen a simple space appear where there was no gap before. Is this what you saw? Commented May 29, 2017 at 13:06
  • 2
    @AndrasDeak: that's very much what seemed to be happening. Commented May 29, 2017 at 13:09
  • @AndrasDeak: Luckily that wouldn't be much of a problem for questions and answers where tabs are really necessary, because makefiles only use tabs for indentation and not in the middle of lines.
    – Ben Voigt
    Commented May 30, 2017 at 5:18

1 Answer 1

9

As I was fixing tabs to spaces, the display would sometimes run words together, but when I inserted a space, it would behave as if there was a tab between the words after all.

As Andras pointed out in the comments section, this "running together" of words is a visual artefact of the first word reaching right up to the next tabspace. So, to you, it didn't look like there was a tabspace in between them, but there was. When you added a new (conventional) space, this pushed the second word into the next column. This would have "felt" like typing Space had the effect of typing Tab, but in fact this was not the case.

If we look at the source of the original revision, copy/paste it into an editor and turn on whitespace mode (), we can see that every token was bizarrely delimited by precisely one tabspace character (except the "greetings" paragraph at the end, for which he finally switched to spaces).

18
  • 3
    In a visual editor, something which is "only" a visual artefact can still be a bug. In a fixed-space font, tabs shouldn't occupy less space than a single character.
    – Ben
    Commented May 30, 2017 at 13:55
  • 3
    @Ben: Tabs are by definition not fixed-space, regardless of the font. We can call it a bug in the editor but, if we do, we have to then also raise a bug in every other text editor, because this is conventional behaviour. Do you also propose that the hundreds of various Unicode characters that are smaller than a space (or take no space at all) should be rendered contrary to the relevant standard? Commented May 30, 2017 at 13:56
  • 2
    Tabs are not fixed space but they occupy non-zero space. Although in non-fixed fonts this non-zero space can be very small, in a fixed font it's always a multiple of the character width, and if (as reported in this case) it isn't that would be a bug.
    – Ben
    Commented May 30, 2017 at 14:23
  • 1
    @Ben: "Tabs [..] occupy non-zero space" Do you have a citation? I can find no evidence of this (on an admittedly brief websearch). Commented May 30, 2017 at 14:32
  • The only actual specification I can find without spending inordinate effort is for the HTML3.2 pre tag: The horizontal tab character (...) should be interpreted as the smallest non-zero number of spaces which will leave the number of characters so far on the line as a multiple of 8. I should have said that in code editors it's a multiple of character size (because the tab stops are specified in characters). However, in Word tabs are specified in fractions of a point, and experimentation shows that a tab can occupy as little as -0.3 pt. So, Negative. Not all editors after all.
    – Ben
    Commented May 30, 2017 at 16:24
  • 1
    @Ben: I don't see what the HTML 3.2 pre tag has got to do with this. That's a completely unrelated/irrelevant citation. A proper citation would be from the Unicode standard, although again I can find no evidence to back up your claim (and I really did try). "Not all editors after all." Microsoft Word is a word processor, not a text editor. Nobody is talking about Microsoft Word. Commented May 30, 2017 at 16:27
  • If you don't see the relevance, then I guess you just don't see it. ... The Unicode standard states that The meaning of tab is defined by ISO/IEC6429/Ecma-048, and has no further comment on it. That standard says, essentially, that a tab moves the "active presentation position" to the next tab stop, which is defined relative to a fixed character pitch, (and since "next" excludes "current" that applies even if you are already at a tab stop). Which I think you would have guessed. So if you are appealing to Unicode, it's still a bug.
    – Ben
    Commented May 30, 2017 at 17:13
  • 1
    @Ben: It's not that "I don't see" a relevance; it's that there isn't one. The description you just quoted matches the current behaviour just fine. Again, if you want to consider this a bug then that's fine but (a) you'll have to raise it against almost every other text editor, and (b) I would vote for a WORKSFORME resolution every time. Commented May 30, 2017 at 17:21
  • 2
    Name another text editor which does this which needs this bug raised. Just one.
    – Ben
    Commented May 30, 2017 at 17:50
  • 8
    This is not conventional behavior. I don't know what text editors you're used to if you got the impression that almost every text editor behaves this way, but every editor I was able to test with (Notepad2, vi, IntelliJ IDEA, Eclipse, and text boxes in Chrome) pushes tabs out to the next tab stop instead of making them zero-width if the tab starts at a tab stop. Commented May 30, 2017 at 17:52
  • @user2357112: Feel free to write your own, competing answer. Commented May 30, 2017 at 18:15
  • 3
    My 40 years of experience is consistent with @user2357112's assertion. In fixed-width environments, TAB has always taken up at least one column.
    – Barmar
    Commented May 30, 2017 at 18:15
  • 2
    I don't accept this analysis that the editor is OK but the data is wrong (though the data is eccentric). Where there's a tab in the data, there should be 1-4 spaces (since tabstops are implicitly set at 4), not 0-3 spaces. The image shows how sometimes words are run together, which is unwarranted behaviour — regardless of the (lack of) wisdom in using tabs where spaces are reasonably expected. Commented May 30, 2017 at 20:24
  • 1
    Then downvote and move on. We don't need the same counter-arguments four times. Commented May 30, 2017 at 20:43
  • 1
    I removed the controversial elements from the answer altogether Commented May 30, 2017 at 22:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .