On 31/05/2012 15:39, Leandro T. C. Melo wrote: > On 05/31/2012 02:42 PM, ext Typz wrote: >> Hello, >> >> Today i've had an issue with the switch header/source feature. >> I have a project with 3 files: toto.h, toto_p.h and toto.cpp (typical >> Qt code :-) >> - First, looking at toto.h, select 'switch header/source', which opens >> toto.cpp: so far, so good. 'switch header/source' again brings >> toto.cpp, nice. >> - Next, looking at toto_p.h, select 'switch header/source', which >> opens toto.cpp: so far, so good. >> - Now if i select again 'switch header/source', i go back to >> toto_p.h... which is consistent with the last switch, but i have no >> 'simple' way to get back to toto.h. >> So from this point, the switch header/source always bings: from toto.h >> or toto_p.h to toto.cpp [OK], and from toto.cpp to toto_p.h... >> >> Looking at the code, i see where this comes from: we correctly look >> for matching header/source, but only if we have not stored the match yet. >> After a successful lookup, we store the result (both directions) in a >> map, to allow recalling it quickly. >> >> This is not very usable, but i don't know how we could fix it. One >> idea could be the switch header/source would iterate over the three >> files, so that it goes toto.cpp -> toto_p.h -> toto.h -> toot.cpp...? >> Or maybe it switch to the 'last' used alternative, and cycle other >> alternatives only if i call the switch header/source again immediately >> (with no other action/key press in between): toto.cpp -> toto.h >> (starts with last used alternative) -> toto_p.h -> toto.h ..., while >> switching from header to source is unaffected. >> > > Hi, > > the original motivation for this was to avoid switching to wrong files > in the case they have the same name. This is a relatively common > situation when you have multiple projects in a session. > > Therefore when searching for a file we pick the one with the nearest > patch. But since that's not a very cheap operation we store the results > in a cache as you noticed. > > Perhaps one alternative for this would be not to store the items in > cache when the hit is not exact, which is the case for the private > headers file. They are provided as a somehow artificial match because of > the popularity of this idiom.
As I feel a bit responsible for this, I will try to find a fix for this use-case. Nicolas -- Nicolas Arnaud-Cormos | [email protected] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-independent software solutions _______________________________________________ Qt-creator mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/qt-creator
