T O P I C R E V I E W |
jkmgs |
Posted - Sep 27 2023 : 04:34:09 AM Hi,
I found a case where the IntelliSense suggestion of Visual Assist is not working as expected. I tried to minimize the code as much as I could while it's still showing the same symptoms. That's what I ended up with:
#include <vector>
#include <functional>
class Failing {
public:
double testVal{};
};
class TestSection {
public:
enum class TestEnum : uint8_t {
A
};
void TestMethod() {
std::vector<Failing> Tests{};
TestEnum TestEnum_{ TestEnum::A };
auto start_it = std::find_if(Tests.cbegin(), Tests.cend(), [](const Failing& /*tester*/) { return true; });
auto end_it = std::find_if(start_it, Tests.cend(), [](const Failing& /*tester*/) { return true; });
auto use_condition = (1 == 0) ?
((TestEnum_ == TestEnum::A) ?
std::function([&]() -> bool { return true; })
: std::function([&]() -> bool { return true; }))
: std::function([&]() -> bool { return true; });
for (; start_it != end_it; start_it++)
{
const Failing& notIndexed = *start_it; // when starting to type "notIndexed" in the next line, there aren't any IntelliSense suggestions. When disabling Visual Assist, it works fine.
}
}
};
So when trying to type "notIndexed" at the line after it is declared, it won't suggest it as long as Visual Assist is enabled. I made sure that the indexing finished its work. I hope that helps you to fix this problem.
All the best, Johannes |
12 L A T E S T R E P L I E S (Newest First) |
jkmgs |
Posted - Oct 06 2023 : 03:34:12 AM You are sincerely welcome! :)
I just tried changing this setting, and it works exactly as you wrote. Thus, I get the same results. Hence, if I find myself again in the situation where I am not getting any IntelliSense hints from VA, I will fall back to this option for now.
Hope you can figure out in the long run what is the culprit behind the curtains.
Thanks for the help so far! |
feline |
Posted - Oct 05 2023 : 11:14:16 AM I have the project and settings, many thanks for these.
Can you please try changing the setting:
VA Options -> Enhanced Listboxes -> Source of C/C++ content: Default Intellisense
in your settings it is set to VA, which is reasonable normally. Now just changing this doesn't cause "notIndexed" to get suggested when typing, but if you press CTRL-SPACE while typing to trigger a complete listbox, rather than a suggestion listbox, then it is suggested. Also I am getting a listbox showing the member variables when I type the dot after "notIndexed".
Normally I would expect VA to fall back to the IDE if it could not produce a member listbox, but obviously that isn't happening here.
Assuming you get the same results, you may want to play with the VA suggestions settings, to see what works best for you, depending on how often you are running into this problem. At least knowing the lambda is part of the trigger will help you guess how often the problem is going to appear in your code. |
jkmgs |
Posted - Oct 05 2023 : 09:12:23 AM quote: Originally posted by feline
Have you tried this in a new, default C++ solution? That is how I tested this, along with inside my normal test solution.
I tested it in the fresh C++ Console App project I created last time using Visual Studio 2022.
quote:
If that is how you tested this, would you be able to send me your test solution, along with your settings please. I can then try the same test here, and see what results I get.
I just sent it over, hope that helps to figure out the culprit! :)
All the best, Johannes
|
feline |
Posted - Oct 05 2023 : 08:36:38 AM Have you tried this in a new, default C++ solution? That is how I tested this, along with inside my normal test solution.
If that is how you tested this, would you be able to send me your test solution, along with your settings please. I can then try the same test here, and see what results I get. You can export the settings via:
VA Options -> Performance -> Export Settings IDE tools menu -> Import and Export Settings -> Export selected environment settings
Please send me the files via email:
[email protected]
including this thread ID or URL in the description, so we can match it up. |
jkmgs |
Posted - Oct 05 2023 : 03:08:19 AM quote: Originally posted by feline
Thank you for the details, and for how to fix this. I have put in a bug report for this:
case=150105
Thank you!
quote:
I figured out why I was getting different results, if you Enable IDE intellisense then the variable and its member is suggested. If you Disable IDE intellisense then it is not suggested.
The normal way to disable IDE intellisense is via the setting:
IDE tools menu -> Options -> Text Editor -> C/C++ -> Advanced -> Disable Database = True
so if the extra CPU load from IDE parsing isn't causing a problem you might want to turn the IDE intellisense parser back on for now.
I had the IDE IntelliSense enabled all the time, but it still was not showing for me. In addition, I also always had the "Enable Predictive IntelliSense" and the "Enable extended item filtering for enum types" experimental options turned on: IDE tools menu -> Options -> Text Editor -> C/C++ -> Experimental -> Enable Predictive IntelliSense / Enable extended item filtering for enum types
Maybe there is an additional option that plays a role here if it works for you with IDE IntelliSense enabled. |
feline |
Posted - Oct 02 2023 : 07:56:42 AM Thank you for the details, and for how to fix this. I have put in a bug report for this:
case=150105
I figured out why I was getting different results, if you Enable IDE intellisense then the variable and its member is suggested. If you Disable IDE intellisense then it is not suggested.
The normal way to disable IDE intellisense is via the setting:
IDE tools menu -> Options -> Text Editor -> C/C++ -> Advanced -> Disable Database = True
so if the extra CPU load from IDE parsing isn't causing a problem you might want to turn the IDE intellisense parser back on for now. |
jkmgs |
Posted - Sep 29 2023 : 08:18:20 AM quote: Originally posted by feline Which IDE and version of VA are you using?
Latest version of both as of now: Visual Studio 2022, 17.7.4 VA, 2023.5
quote:
I am now getting the problem, even though I haven't changed the code, and didn't get it before. Trying a second machine, and trying to make sense of this, since I would prefer this to be a consistent problem if possible
Great that you managed to reproduce it on a machine! That's progress :) But yes, having it consistently failing would be the best. Btw. if I comment out the definition of the 'use_condition' variable, everything works as expected again. So if you made sure that you are using exactly the same code on both machines, then I also have no more guesses and hope that you can find any differences between the machines or the saved VA configuration/VA cache files/IntelliSense cache files. Also interesting to note is that if the VA is disabled while typing notIndexed, IntelliSense is taking over and correctly suggesting the variable. |
feline |
Posted - Sep 28 2023 : 12:06:59 PM Please don't worry about it, code samples normally don't compile, but when you have odd problems checking the code compiles is a good first step.
Which IDE and version of VA are you using?
I am now getting the problem, even though I haven't changed the code, and didn't get it before. Trying a second machine, and trying to make sense of this, since I would prefer this to be a consistent problem if possible |
jkmgs |
Posted - Sep 28 2023 : 03:30:54 AM quote: Originally posted by feline
Please don't apologise, I am just trying to understand the problem.
My intention was to showcase you the problem, not having you trying around to get it even to compile. I don't want to waste your time. :)
quote:
Do you mean you are typing on a NEW line, after the variable "notIndexed" has already been defined? If so, the variable IS being suggested for me.
Exactly, this is what I am doing. Strange, for me it is NOT being suggested.
quote:
This version of the code complies quite happily for me, thank you for the edited version of the code.
Happy to hear that!
quote:
Do you have:
VA Options -> Coloring and Attributes -> Show local symbols in bold
turned On or Off? With this setting turned On, "notIndexed" is being shown in bold for me on the line where it is declared. If it is not being shown in bold for you then this would be a clue, since it would tell us that VA is not properly picking this up as a local variable. Obviously if VA doesn't understand that this is a local variable for some reason then this would be why it isn't being suggested for you.
I have this setting turned off. I just activated it. "notIndexed" is now being shown in bold for me, so it correctly identified it as a local variable. Still, I am experiencing the symptoms from above. "notIndexed" is not being suggested when I start typing, nor is it suggesting anything when I fully type "notIndexed." myself.
I will send you a gif per mail showcasing the issue.
All the best, Johannes |
feline |
Posted - Sep 27 2023 : 11:55:46 AM Please don't apologise, I am just trying to understand the problem.
Do you mean you are typing on a NEW line, after the variable "notIndexed" has already been defined? If so, the variable IS being suggested for me.
This version of the code complies quite happily for me, thank you for the edited version of the code.
Do you have:
VA Options -> Coloring and Attributes -> Show local symbols in bold
turned On or Off? With this setting turned On, "notIndexed" is being shown in bold for me on the line where it is declared. If it is not being shown in bold for you then this would be a clue, since it would tell us that VA is not properly picking this up as a local variable. Obviously if VA doesn't understand that this is a local variable for some reason then this would be why it isn't being suggested for you. |
jkmgs |
Posted - Sep 27 2023 : 08:43:15 AM Hi feline,
1. Yes, it should compile of course, my apologies. It compiles fine in my project here, but not in a fresh Console App project. So I updated the code below. It compiles now in a fresh C++ Console App project created using Visual Studio 2022:
#include <iostream>
#include <vector>
#include <functional>
class Failing {
public:
double testVal{};
};
class TestSection {
public:
enum class TestEnum : uint8_t {
A
};
void TestMethod() {
std::vector<Failing> Tests{};
TestEnum TestEnum_{ TestEnum::A };
auto start_it = std::find_if(Tests.cbegin(), Tests.cend(), [](const Failing& /*tester*/) { return true; });
auto end_it = std::find_if(start_it, Tests.cend(), [](const Failing& /*tester*/) { return true; });
auto use_condition = (1 == 0) ?
((TestEnum_ == TestEnum::A) ?
std::function<bool()>([&]() -> bool { return true; })
: std::function<bool()>([&]() -> bool { return true; }))
: std::function<bool()>([&]() -> bool { return true; });
for (; start_it != end_it; start_it++)
{
const Failing& notIndexed = *start_it; // #1 at this line I create the variable
// #2 at this line you have to start typing "notIndexed", and the expected outcome would be to see the correct IntelliSense suggestion. You can also type "notIndexed.", and I would expect it to propose me "testVal", since this is the only public property of the "notIndexed" object.
}
}
};
int main()
{
std::cout << "Hello World!\n";
}
2. I tried to explain it in another way in the comments above. Hope it is clearer now. I already have the variable created at the point where the IntelliSense fails.
All the best, Johannes
|
feline |
Posted - Sep 27 2023 : 07:56:18 AM Should this code compile? It is failing to compile for me, having placed this into a header file, using VS2022. I am getting the build error that std::function requires a template argument list. I ask since sometimes VA won't work as you expect since it cannot understand the code, due to the code not compiling.
But that isn't going to be the problem here. When you are typing "notIndexed", since you are declaring a new variable, VA won't always offer a suggestion here, depending on your settings. Since this is a new variable, we have no reason to assume we have any sensible suggestions for what you are going to call it.
Are you expecting VA to suggest a new variable name here? Or am I not understanding what you mean? |
|
|