Hello, Indeed, maybe when the match is not exact, we should not store the 'reverse' association. That way, we would end up storing in the map: .cpp -> .h and .h -> .cpp when the function is used on either .cpp/.h, and _p.h -> .cpp when used on the private header.
Best regards, -- Francois On Thu, May 31, 2012 at 3:39 PM, Leandro T. C. Melo <[email protected]>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. > > > Cheers, > Leandro > > > > > > > > _______________________________________________ > Qt-creator mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/qt-creator > >
_______________________________________________ Qt-creator mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/qt-creator
