clangd in the presence of compilation error can navigate to completely irrelevant destinations. This is often a problem for headers that cannot be compiled standalone. For example, go-to-def often jumps to containing namespace because the selection tree just consists of namespace (when relevant AST nodes were missing due to compilation error). This is known issue that is hard to solve without using some heuristic. One such heuristic is to check the nodes in the selection tree for the exact line match. In the absence of such match, we do not provide navigation. IMO, this is better than jumping to wrong position.
- This currently does not have test cases but I will add test cases based on the feedback for the heuristic.
- Enable only when there is compilation error.