tintoy / msbuild-project-tools-vscode

VS Code extension for MSBuild intellisense (including PackageReference completion).
MIT License
82 stars 16 forks source link

VSCode suggestions results in an extra "<" #67

Closed AndrewTriesToCode closed 2 years ago

AndrewTriesToCode commented 4 years ago

In VSCode on MacOS when starting to add a new tag in a .csproj file I start by typing and when the suggestions are shown I hit enter to pick the right one. This result in two "<" at the start of the line rather than one.

For example <langver> gets autocompleted as <<langver> which is invalid syntax.

Thanks!

tintoy commented 4 years ago

Hi, thanks for reporting - I’ll see if I can reproduce this tomorrow morning :)

tintoy commented 4 years ago

Hmm, yep - I see the same behaviour. I guess they must have changed behaviour somewhere in the extension API 🙄

I'll try to get this fixed tomorrow morning (sorry, work's a bit crazy at the moment)!

AndrewTriesToCode commented 4 years ago

@tintoy thanks! I know what you mean I have a semipopular open source library and a full-time job--hard to balance sometimes.

tintoy commented 4 years ago

Ok, I can at least see a way to fix this, although it may take a while longer to work out why it has started happening. It seems that text positions (i.e. the insertion point) in LSP messages sent to our language service to request completions no longer include the position of the character that triggered completion (if there was one).

I suspect this is because newer versions of LSP actually include information about whether completion was triggered by a character (but we'd need to upgrade our LSP libraries and there are some pretty big incompatibilities on how those work these days - we were quite an early adopter and I've never had the time to upgrade given how disruptive it looked like it would be).

If these changes don't do the trick I guess I'll have to bite the bullet and do it the hard way ;-)

tintoy commented 4 years ago

Ok, I think I've got it working correctly now. Would you mind giving it a try by removing the extension and installing it from this VSIX package?

msbuild-project-tools-0.3.8.zip

AndrewTriesToCode commented 4 years ago

@tintoy Thanks for the quick reply. I uninstalled and installed via the VSIX package. So it works if you select the first item, but if you arrow down and select another one it still adds the extra "<".

On another note, I most often use this with and it seems that it doesn't suggest this until well into typing it out--further than I would expect. Any viscose settings I should tweak related to that?

tintoy commented 4 years ago

That’s odd - I can’t reproduce that myself, would you mind turning up the log level for the extension and posting the log here? It should only be performing a single completion call.

AndrewTriesToCode commented 4 years ago

Sure, I put the log on verbose and set a log file to ~/log.txt but I don't see a file there or anything in the output for MSBuild Project Tools window. If you can instruct me how to configure thatI'd be glad to.

To get the error I created a basic project with dotnet new mvc then I open up the .csproj file in vscode and in ItemGroups I type "<PackageRef" or how ever many characters I need to see it, then arrow down and select it, resulting in the extra starting character. I notice if I select the first option it always works fine, and often others are ok. Maybe this one is different because it has attributes like Include and Version? I had autosave on which really compounded the problem (omnisharp will try to repart the csproj file mid edit if I pause in typing), but I took it off to make things less difficult.

tintoy commented 4 years ago

PackageReference elements are a special case unfortunately :-/

Does it happen with consistently with any other element types?

tintoy commented 4 years ago

All you need to configure for logging in the VSCode settings JSON is:

{
   "msbuildProjectTools.logging.level": "Verbose"
}

Then you should see an output window pane called "MSBuild Project Tools":

image

tintoy commented 4 years ago

Ok, now it's happening for me but semi randomly. They really seem to have done something weird with the LSP behaviour. I'll let you know what I find.

tintoy commented 4 years ago

Righto, figured out the problem. I'll get it fixed and get a new build up for you to try as soon as I can :)

AndrewTriesToCode commented 4 years ago

Awesome thanks. I was trying to get a good log capture for you but I couldn't made much sense of it all. Looking forward to the fix. Also for what it is worth another good test case is DotNetCliToolReference.

tintoy commented 4 years ago

Cool - hopefully this one will work:

msbuild-project-tools-0.3.8.zip

(the problem before was that I was only trying to handle the trigger characters when replacing an existing element, not when inserting a new one; so, you know, not the actual scenario you reported 😉)

AndrewTriesToCode commented 4 years ago

Hm, now when I hit the trigger character my log shows this and I don't get any completions:

System.NullReferenceException: Object reference not set to an instance of an object.
   at async Task<CompletionList> MSBuildProjectTools.LanguageServer.CompletionProviders.CommentCompletion.ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken) in /Users/acw/Dev/defaultmvc/C:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\CommentCompletion.cs:line 79
   at async Task<CompletionList> MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler.OnCompletion(CompletionParams parameters, CancellationToken cancellationToken) in /Users/acw/Dev/defaultmvc/C:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Handlers\CompletionHandler.cs:line 202
tintoy commented 4 years ago

☹️ 🤣

Ok, let's try that again:

msbuild-project-tools-0.3.8.zip

tintoy commented 4 years ago

(as you can see, that was a stupid copy-paste bug)

AndrewTriesToCode commented 4 years ago

Perfect! I can appreciate a good copy-paste mistake. Appreciate the quick turn around on this.

tintoy commented 4 years ago

Great! Thanks again for trying it out - I’ll give it a full run-through tomorrow and then publish a new version in the gallery (given the size of the audience I’m paranoid about publishing without checking nothing else has been broken)...

pm4rcin commented 2 years ago

@tintoy I guess it can also be closed. :)

tintoy commented 2 years ago

Thanks!