#548 Flux bug - tabstops not quite right

KevinKelley Wed 22 Apr 2009

Just by the way, there's a thing in Flux where, if you're using the convert tabs to spaces option, then if you type a space then a tab, it inserts (tabstop) spaces when it should insert (tabstop - 1). Upshot is that it takes you off the proper indent positions.

Here's a (not very pretty) fix. In flux/fluxText/fan/Parser.fan, about line 74, change

if (options.convertTabsToSpaces)
  text = text.replace("\t", Str.space(options.tabSpacing))

to

while (options.convertTabsToSpaces && text.containsChar('\t'))
{
  i := text.index("\t")
  ts := options.tabSpacing
  text = text.slice(0..<i)
    + Str.spaces(ts - (i % ts))
    + (i + 1 < text.size ? text.slice(i + 1 .. -1) : "")
}

brian Wed 22 Apr 2009

Promoted to ticket #548 and assigned to brian

OK - it looks like this is related to when we first load a file into the editor (versus typing in the editor - that part appears right). I think we want something a little more efficient for the real fix though.

tompalmer Fri 24 Apr 2009

Side question, any chance for elastic tabs in Flux? I think it could be done well, maybe. (But I'm off topic here, sorry.)

brian Fri 24 Apr 2009

Side question, any chance for elastic tabs in Flux? I think it could be done well, maybe. (But I'm off topic here, sorry.)

My understanding of that is that you still store/visualize an actual tab character. Whilst I don't want to discourage anyone from submitting patches, I personally think tabs in source code are evil :-) But we all know how touchy people get about spaces vs tabs.

KevinKelley Fri 24 Apr 2009

Nice!

tompalmer Fri 24 Apr 2009

Whilst I don't want to discourage anyone from submitting patches ...

I'll keep that in mind. Might happen again from me someday.

tactics Fri 24 Apr 2009

I'm not sure the exact reasons why Brain and Andy chose to use two spaces as the standard for Fan, but it always seemed like a nice way to sweep the tab issue under the rug. Seriously, a two space tab is insane ;-)

qualidafial Fri 24 Apr 2009

Seriously, a two space tab is insane

I use two-space tabs, you insensitive clod! ;)

brian Thu 30 Apr 2009

Ticket resolved in 1.0.42

Login or Signup to reply.