Skip to content
  • Christoph Cullmann's avatar
    [PATCH] Quick Open: fix LRU listing regression · 2fdd8c14
    Christoph Cullmann authored
    The quick open list used to be sorted by order of access (the old code
    called it LRU order). Commit d6e38c0c broke this.
    
    The first sort() call is changed to stable_sort() in order to preserve
    the "bold" field and the new "sort_id" field. A comment warns about this
    subtle and easy to break requirement. This change was needed to sort the
    file list by LRU (files not in the sortedViews list have no sort_id set,
    and thus are sorted below all LRU sorted entries).
    
    stable_sort() should be slower than sort(), although the C++ standard
    promises the same algorithmic complexity. On the other hand, this change
    also lets us get rid of the openedUrls string list and the associated
    linear search.
    
    The second sort must always be a stable_sort(). This is a bug in the
    previous code. It sorted only on the "bold" field, which means
    everything else can be reordered as sort() likes. Even if it "worked",
    it was buggy.
    
    To completely restore the old behavior, select the second entry by
    default in the quick open list. This is so that you can quickly switch
    between the two last recently accessed files. The old code actually
    selected the first entry if the sortedViews list contained less than 2
    elements - keep that behavior too.
    
    Author: Vincent Lang
    
    BUG: 407103
    2fdd8c14