[txmt-dev] Re: Git outputs filled with <NUL>

Fred B fredb7 at gmail.com
Wed Sep 26 23:42:18 UTC 2012


On 26 Sep 2012, at 14:48, Allan Odgaard <mailinglist at textmate.org> wrote:

> On Sep 21, 2012, at 4:03 PM, Fred B <fredb7 at gmail.com> wrote:
> 
>> [ HTML output ]
>> […] it would be nice to choose the location in the command […]
> 
> You think this should be decided by the command author?
> 
> Or you mean, be an option per command? Probably with [ default, split, window ] and user can then set a global default but also change it on a per command basis.

I mean the latter, that would be perfect.

>> - I use a web theme with a much slimmer bar (I made a dark version of scott (https://github.com/wafflesnatcha/scott.textmate)).
> 
> Neat! I converted this output theme to a bundle:
> 
>    https://github.com/wafflesnatcha/scott.textmate/pull/1

In case I didn't make myself clear enough, I'm not the author of this web theme (or I'll be named Scott, I guess ;).
I just made a dark background version of it. I'll convert it to a bundle and try to put it on github this week end.
I know, I have a dark background issue… ;)

>> […] Changing `@output_buffer.truncate(0)` with `@output_buffer = StringIO.new` seems to work, but I'm not sure there is any downside […]
> 
> To me, StringIO#truncate looks buggy:

Good catch. I quickly tested truncate(0) and saw no problem, but apparently it happens when you add to the buffer after truncating it.
In fact, if you truncate it to more bytes than the actual buffer length, it adds \000s too.

Same on Ruby 1.8.7 and 1.9.3, btw.

I was sure I tried before and it didn't work but it seems simply using `@output_buffer.string = ""` works perfectly fine and shouldn't cause any problem. I sent a pull request with just that change.

P.S: Although I don't see why it would be better, another solution is to use `@output_buffer.rewind` after `@output_buffer.truncate(0)`

> Based on the above test, it would seem it outputs as many zeros as the max length of bytes that has been added to the string buffer, at least doubling the output size.

In fact it's much more than that, around 30 times the size for the log command.
Git Log on TM2 repo with a log limit of 50: 57KB vs 1.7MB
This is a contrived example and I had to pipe directly to the file to avoid killing TM:
Unlimited TM2 log: 634KB vs 194.4MB (!)




More information about the textmate-dev mailing list