Hmm, not ideal... but would you mind spinning that off as a separate bug?  I fixed one similar bug as part of this pull request (see cases in unit tests), but I think these are basically separate issues from #2761.

#2761 was about a much more confusing issue -- a file is highlighted in the tree but it's not the file shown in the editor.  In this case we just leave the folder highlighted, which is far less likely to be confusing.  (And we already have a number of cases where a folder is even _expected_ to be highlighted in the tree instead of the file that's open, so it's probably something users will have seen before).