Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intellisense errors by moving TerminalApp projects around #6897

Merged
2 commits merged into from
Aug 20, 2020

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Jul 13, 2020

The easiest fix was actually just moving all the source files from
TerminalApp to TerminalApp/lib, where the appropriate pch.h
actually resides.

Closes #6866

@ghost ghost added Area-Build Issues pertaining to the build system, CI, infrastructure, meta Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Jul 13, 2020
@rpjohnst
Copy link

FYI in case you are interested in pushing this further- this approach will prevent IntelliSense from actually pre-compiling that header, losing out on that optimization. This means longer pauses after first opening a file, and after making "top-level" edits (i.e. outside the body of a function).

The rule of thumb we (the IntelliSense team) use here is that the build should still work with PCH disabled, and then IntelliSense should automatically work as well. If I understand correctly, then adding lib to TerminalAppLib's include paths shouldn't cause any conflicts (as there are no other header files there), and would allow everything to work.

@miniksa
Copy link
Member

miniksa commented Jul 13, 2020

FYI in case you are interested in pushing this further- this approach will prevent IntelliSense from actually pre-compiling that header, losing out on that optimization. This means longer pauses after first opening a file, and after making "top-level" edits (i.e. outside the body of a function).

The rule of thumb we (the IntelliSense team) use here is that the build should still work with PCH disabled, and then IntelliSense should automatically work as well. If I understand correctly, then adding lib to TerminalAppLib's include paths shouldn't cause any conflicts (as there are no other header files there), and would allow everything to work.

Neither @zadjii-msft or I can tell whether your suggestion means "use the include path INSTEAD of adding the extra PCH to all of the headers" or "use the include path IN ADDITION TO adding the extra PCH to all of the headers." Can you please clarify, @rpjohnst?

@zadjii-msft
Copy link
Member Author

And you know what, I did try just adding $(OpenConsoleDir)\cascadia\TerminalApp\lib\; to <AdditionalIncludeDirectories> in TerminalApp.vcxproj, and removing the lib/pch.h line from TerminalPage.cpp, but that gave me the same list of Intellisense errors as always. Maybe I'm doing it wrong?

@rpjohnst
Copy link

rpjohnst commented Jul 13, 2020

Ah, sorry for the confusion. I meant to suggest using the include path instead of adding the extra #include lines.

And now that you mention that you've tried that, I think I see why it didn't work- #include "pch.h" with "" instead of <> prioritizes the source file's directory over the include search paths, and the wrong PCH happens to be in the source file's directory.

So I tried adding $(OpenConsoleDir)\cascadia\TerminalApp\lib and replacing #include "pch.h" with #include <pch.h> and that seems to be working. (Well, I'm now hitting a different bug where IntelliSense crashes on some coroutines stuff, which TerminalPage.cpp is full of, but at least it's not spitting out errors 🙂)

@zadjii-msft
Copy link
Member Author

Okay, weird. I've tried that too, but now it seems that whenever I open a cpp file with the <pch.h> in it, it will intermittently have intellisense errors in it, until I load up the header for that file. Once intellisense has had a chance to parse the header too, it seems like the errors in the cpp file go away as well.

I have no idea if that's expected or not.

@rpjohnst
Copy link

Hm, that's definitely not expected. A guess at what's happening- perhaps the cpp file you open finds the wrong pch.h, while the header finds the correct one. IntelliSense could then build a working PCH in response to opening the header, which could then be picked up by the cpp file when you return to it.

If so, one thing to double check is the order of the AdditionalIncludeDirectories list. Make sure lib is before the existing ... (Or even replace it, if that doesn't break anything else?) It might also help to temporarily disable PCH use project-wide and make sure the compiler can still find everything.

If that doesn't help, then maybe it's just some leftover state that would go away if you did "Project > Rescan File," restarted VS, and/or deleted the .vs directory. (Fair warning, that will reset a few things like the set of open files; if that's a problem then it may be enough to delete just .vs/<Project>/v16/ipch)

@miniksa
Copy link
Member

miniksa commented Aug 7, 2020

K well. I was having Intellisense issues and I merged this into my branch and they're gone. Well, Intellisense is still slow but that's par for a WinRT project. So I don't care if there's a better way, this is better than 100% broken as it is now.

@zadjii-msft zadjii-msft force-pushed the dev/migrie/f/fix-intellisense-i-guess branch from 5a316b7 to ef40fd3 Compare August 7, 2020 21:32
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a spare pch file to delete after this?

@DHowett
Copy link
Member

DHowett commented Aug 7, 2020

It might be even easier to move the lib project into the TerminalApp/ folder and make a dll project that just dllizes it

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, i might block to discuss that

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 7, 2020
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Aug 15, 2020
@ghost
Copy link

ghost commented Aug 15, 2020

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@zadjii-msft zadjii-msft force-pushed the dev/migrie/f/fix-intellisense-i-guess branch from ef40fd3 to ebf75ed Compare August 20, 2020 16:10
@ghost ghost removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Aug 20, 2020
@zadjii-msft zadjii-msft changed the title Fix intellisense errors by manually including TerminalAppLib's pch.h Fix intellisense errors by moving TerminalApp projects around Aug 20, 2020
Comment on lines 29 to +39
<!-- Only put headers for winrt types in here. Don't put other header files
in here - put them in TerminalAppLib.vcxproj instead! -->
<ClInclude Include="AppLogic.h" />
<ClInclude Include="../AppLogic.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="TerminalPage.h" />
<ClInclude Include="MinMaxCloseControl.h" />
<ClInclude Include="AppKeyBindings.h" />
<ClInclude Include="TitlebarControl.h" />
<ClInclude Include="TabRowControl.h" />
<ClInclude Include="App.h" />
<ClInclude Include="Tab.h" />
<ClInclude Include="../TerminalPage.h" />
<ClInclude Include="../MinMaxCloseControl.h" />
<ClInclude Include="../AppKeyBindings.h" />
<ClInclude Include="../TitlebarControl.h" />
<ClInclude Include="../TabRowControl.h" />
<ClInclude Include="../App.h" />
<ClInclude Include="../Tab.h" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the dll project even need the ClIncludes? Can it live w/o them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably?

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 20, 2020
@ghost
Copy link

ghost commented Aug 20, 2020

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit e238dcb into master Aug 20, 2020
@ghost ghost deleted the dev/migrie/f/fix-intellisense-i-guess branch August 20, 2020 22:44
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Build Issues pertaining to the build system, CI, infrastructure, meta AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra IntelliSense errors caused by include paths and precompiled headers
4 participants