LaTeX-Box-Team / LaTeX-Box

Lightweight Toolbox for LaTeX - New Official repository
http://www.vim.org/scripts/script.php?script_id=3109
GNU General Public License v3.0
396 stars 66 forks source link

fix bug #227 error in ReadTOC function #228

Closed ThomasFeher closed 9 years ago

ThomasFeher commented 9 years ago

Checks if list entry is a string before comparing it to a string. In rare cases this could be a list of strings which results in an error message.

lervag commented 9 years ago

From vims documentation:

                            *type()*
type({expr})    The result is a Number, depending on the type of {expr}:
            Number:     0
            String:     1
            Funcref:    2
            List:       3
            Dictionary: 4
            Float:      5
        To avoid the magic numbers it should be used this way: >
            :if type(myvar) == type(0)
            :if type(myvar) == type("")
            :if type(myvar) == type(function("tr"))
            :if type(myvar) == type([])
            :if type(myvar) == type({})
            :if type(myvar) == type(0.0)

Thus I think you should use type(...) == type("").

It would be better if you could fix the problem also for the rare cases, but if you make the above change I will merge the pull request.

ThomasFeher commented 9 years ago

Ok, I didn't read the documentation thoroughly enough. That magic number is now fixed. I also tried to improve the commit message to make clear that this commit actually fixes the rare case.

I squashed everything in one commit. I'm not sure whether I have to to make a new pull request now.

lervag commented 9 years ago

Great, thanks! Good work!