boysetsfrog / vimpc

Official repository for vimpc a vi/vim inspired client for the Music Player Daemon (mpd). Pull requests are welcome.
GNU General Public License v3.0
269 stars 34 forks source link

Default sort option does not behave well with track numbers in "browse" window #62

Closed geo909 closed 5 years ago

geo909 commented 8 years ago

Hi,

First thanks for this great program, I love it.

I have the following in my rc file: (note that the formats are identical)

set songformat {%a - %b - %n.%t}|{%f}$E$R $H[$H%l$H]$H
set libraryformat {%a - %b - %n.%t}|{%f}$E$R $H[$H%l$H]$H

Then what happens is that in my "browse" window, tracks that are numbered 1, 2, ..., 9, 10, 11, appear like so:

Artist - Album - 1.First track
Artist - Album - 10.Tenth track
Artist - Album - 11.Eleventh track
Artist - Album - 2.Second track
.
.
.
Artist - Album - 9.Ninth track

However if I set

set sort library

Then the tracks appear in the right order:

Artist - Album - 1.First track
Artist - Album - 2.Second track
.
.
.
Artist - Album - 9.Ninth track
Artist - Album - 10.Tenth track
Artist - Album - 11.Eleventh track

I thought the default is that sort is set to "format", which is exactly the same as with the libraryformat in my rc. So, wouldn't it be the expected behaviour that the default should result the tracks to show as in the second case?

Thanks.

boysetsfrog commented 8 years ago

The issue is that the "format" search option is purely a dumb alphabetical sort on the format string. The library sort option however is not based on the library's format string but is based upon the order of the song library itself which is sorted with understanding that track number comes before title etc. The "libraryformat" option purely controls the printing, not sorting. What is really needed is a proper sort that understands that context for the browse window, or simply a print that puts a leading "0" on the track numbers.

It's definitely not really the intended behaviour but i guess it's somewhat sort of expected. I'll see what I can do.

geo909 commented 8 years ago

Ah, okay, I see what the problem is. Printing a leading zero on the track number can also be tricky in the (admittedly very rare) case of albums with more than 100 tracks, though.

In any case, personally I put "set sort library" and I'm happy, I just wanted to bring it to your attention. Thanks again.