Skip to content

Intellisense not working properly #4059

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

Closed
6 tasks done
functionkey-12 opened this issue Jun 30, 2022 · 17 comments
Closed
6 tasks done

Intellisense not working properly #4059

functionkey-12 opened this issue Jun 30, 2022 · 17 comments
Assignees
Labels
Issue-Bug A bug to squash.

Comments

@functionkey-12
Copy link

functionkey-12 commented Jun 30, 2022

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Intellisense is no longer working consistently. cmdlets that have not been used earlier within the workspace will not tab-complete, or provide any information.

This is very similar to #179. As suggested in #179, I have uploaded the editorservices.log

I have disable, uninstalled, and re-installed the PowerShell extension. I have rebooted VSCode many times, and have rebooted my machine as well. No change.

PowerShell Version

PS 7.2.5> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

PS 7.2.5> code --version 
1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64

Extension Version

PS 7.2.5> code --list-extensions --show-versions | Select-String powershell

[email protected]
[email protected]

Steps to Reproduce

Typing get-pro will not autocomplete to any cmdlet. Instead it inserts a tab. The same happens with new-obj. Pressing ctrl+space yields no results.

However, Get-PSCallstack, which has been used earlier in the .ps1, and elsewhere in the workspace, autocompletes fine.

Visuals

VSCode-GetPSCallStack
VSCode-GetProcess
VSCode-NewObject

Logs

EditorServices.log

@functionkey-12 functionkey-12 added the Issue-Bug A bug to squash. label Jun 30, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jun 30, 2022
@andyleejordan
Copy link
Member

Hi, I can't seem to repro this, it's working fine for me:
Screen Shot 2022-06-30 at 2 22 08 PM

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@andys-mac-mini ~/src/vscode-powershell main ≡
> $psEditor      

EditorServicesVersion Workspace                                                      Window
--------------------- ---------                                                      ------
3.4.5.0               Microsoft.PowerShell.EditorServices.Extensions.EditorWorkspace Microsoft.PowerShell.EditorServices.Extensions.EditorWindow

Can you share your settings.json?

@andyleejordan
Copy link
Member

However, Get-PSCallstack, which has been used earlier in the .ps1, and elsewhere in the workspace, autocompletes fine.

This makes me think you have editor.wordBasedSuggestions enabled (which is just Code suggesting completions based on other tokens in your open files, which is what you're describing), but I think perhaps you don't have actual LSP completions enabled, or your extension isn't correctly started.

Can you share the value of $psEditor in your integrated console?

@andyleejordan andyleejordan added Needs: Repro Info 🤔 and removed Needs: Triage Maintainer attention needed! labels Jun 30, 2022
@functionkey-12
Copy link
Author

functionkey-12 commented Jul 1, 2022

PS 7.2.5> $psEditor     

EditorServicesVersion Workspace                                                      Window
--------------------- ---------                                                      ------
3.4.3.0               Microsoft.PowerShell.EditorServices.Extensions.EditorWorkspace Microsoft.PowerShell.EditorServices.Extensions.EditorWindow

settings - Copy.txt

@functionkey-12
Copy link
Author

I did have editor.wordBasedSuggestions enabled. I have turned it off, and the problem persists.

@tmknight
Copy link

tmknight commented Jul 1, 2022

I am seeing that the language service isn't fully loading since "PowerShell Integrated Console v2022.6.1" on two different machines (albeit with settings sync) with Windows PowerShell as well as PowerShell Core 7.2.5. I believe this is preventing intellisense from functioning:
image
image
image

extension services output:

at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.TryStartAsync(HostStartOptions startOptions, CancellationToken cancellationToken) in D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 275
   at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle(InternalInitializeParams request, CancellationToken token)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() | Method='initialize' RequestId='0'
[Warn  - 2:12:26 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError | @Request='OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError'

About code:

Version: 1.68.1 (system setup)
Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630
Date: 2022-06-14T12:48:58.283Z
Electron: 17.4.7
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Windows_NT x64 10.0.19044

@functionkey-12
Copy link
Author

I assume Needs: Repro Info 🤔 means I need to give reproduction information.

I type in a cmdlet, or a function that is loaded into running memory and then press tab. Tab completion does not work, nor do I get any information on the cmdlet. Pressing ctrl+space does not yield any results.

--

Updated PowerShell extension to v2022.6.3, and there has been no change.

I do not get the same notification from the extension that tmknight gets.

@andyleejordan
Copy link
Member

@functionkey-12 I believe your issue is simply that your extension is not starting correctly. Let's diagnose that. Can you and @tmknight both follow these steps to get us detailed logs around the startup?

@andyleejordan
Copy link
Member

@tmknight your log points me to this code. Can you please check your setting for the initial working directory, and be certain that it a) exists and b) has open enough permissions for the extension to cd to it?

@functionkey-12
Copy link
Author

Here are my logs. It should all logs after a restart of the application.

I continued to add new code to my workspace, and due to this New-Object now auto-completes. However, get-pr does not suggest anything.
2022-07-01-Logs.zip

@tmknight
Copy link

tmknight commented Jul 1, 2022

@tmknight your log points me to this code. Can you please check your setting for the initial working directory, and be certain that it a) exists and b) has open enough permissions for the extension to cd to it?

Took some digging through settings.json, but found this to resolve my issue (now commented):
// "powershell.cwd": "",
Hard to remember if I changed it, though had no issues until the upgrade to the current PS integrated console the other day,
image
I just tested adding a value, then removing the value. It leaves behind in settings.json the empty value that breaks PS integrated console from completely starting...seems a bug to me that it should not allow an empty value and either remove the line completely or at least throw a warning if you clear a previously set attribute that will now break code.

@andyleejordan
Copy link
Member

Woah, good catch @tmknight! Yes, we recently fixed the initialization sequence so that non-VS Code clients would work again, and in doing so now directly execute essentially cd <that string>. Thing is, it seemed like we wouldn't need to test that it exists, since the client checks too...but you found the edge case where the client is happy and the server is not. We'll get it fixed! Thank you for checking.

@functionkey-12
Copy link
Author

I have never set the powershell.cwd setting, so it was not present in my settings.json.

I decided to set it and see if anything changes. It did not. I have since removed it.

@functionkey-12
Copy link
Author

I started in on my settings.json file, and commented out everything to see if the issue was still present. It was not. slowly uncommented sections till the problem re-emerged. Then narrowed it down to the setting editor.suggest.showfunctions, which was set to false. set it to true, and the uncommented the reset of my settings, and... no issue.

So this is not an issue with the powershell extension, just an issue with me. Don't ever remember setting this preference, but regardless, intellisense is back for me. I will go ahead and close this issue.

@andyleejordan
Copy link
Member

Woo, good work @functionkey-12 finding that! I went and looked real hard for a setting like that myself, but didn't find one. I'll get it added to the troubleshooting guide.

@Pxtl
Copy link

Pxtl commented Aug 9, 2023

I just hit the same failure.

Reviewing my logs:

The variable '$IsWindows' cannot be retrieved because it has not been set.

@andyleejordan
Copy link
Member

@Pxtl the only thing in PSES which uses that is the shell integrations script, can you try disabling it via terminal.integrated.shellIntegration.enabled?

@Pxtl
Copy link

Pxtl commented Aug 9, 2023

@Pxtl the only thing in PSES which uses that is the shell integrations script, can you try disabling it via terminal.integrated.shellIntegration.enabled?

Yes, I tried that and it has resolved the issue, thanks. I don't love it as a workaround but since I don't recall ever noticing any impressive integration on the integrated powershell console, I doubt I'll miss it. I tend to use an external powershell console anyways unless I'm running in the debugger. Hopefully the VSCode team resolves the issue properly... or Microsoft force-updates everybody to PSCore so I no longer have to support PS5.1 machines. But I suppose the PS Core team finds it easier to develop a language when they don't have actual users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants