Cleaner fix for #2761 (Project tree selection incorrect after opening file by means other than sidebar)

Cleaner fix for #2761 -- Clear selection in project tree if current document not exposed in tree anywhere.

Backs out pull #2869, which made the behavior of Find in Files inconsistent with other means of opening files and didn't fix other cases of the bug.

Adds unit tests for several of these edge cases.