A fix for issues/6: Colspan in first row breaks layout #7

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@niko
niko commented Aug 5, 2011

#6

@scottjg
Collaborator
scottjg commented Oct 16, 2011

hi. sorry for the delay, i'm going through the backlog of patches now. it seems the code has now changed enough that this patch no longer seems to fix the attached test. if you wouldn't mind fixing it up, i would be happy to merge. keep in mind that a bunch of the other tests are also now broken (i am in the process of fixing them)

@rrrene
Contributor
rrrene commented Oct 16, 2011

This is a pretty easy fix now: in lib/terminal-table/table.rb

    def number_of_columns
      if rows.empty?
        raise Error, 'your table needs some rows'
      else
        rows.first.size
      end
    end

Just replace rows.first.size with

rows.map { |r| r.size }.max

This "searches" the whole table for the maximum number of columns.

@nateberkopec
Collaborator

It looks to me as if the fix above by @rrrene was applied with 4165427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment