tareqimbasher / NetPad

A cross-platform C# editor and playground.
MIT License
1.4k stars 70 forks source link

Autocomplete Feature Missing #230

Open ThunderCls opened 4 months ago

ThunderCls commented 4 months ago

Is it me or autocompletion is missing? I'm using v0.7.2 and nothing is shown when I try to access an entity property or function, or try to use anything like LINQ

tareqimbasher commented 4 months ago

Hello @ThunderCls. NetPad does have autocompletion and should work out of the box. When you first start NetPad it downloads then starts OmniSharp which powers a number of editor features like autocompletion, syntax highlighting, code lens...etc. If you find that these features do not work for you, can you take a look at the log files, there's a good chance the issue would be logged there. The easiest way to get to them is to open Settings (F12) and then click the "Open App Data Folder" button and check the Logs folder.

ThunderCls commented 4 months ago

It's really weird. These logs are sticking out tho

2024-07-11T14:22:38.9940315-04:00 [WRN] (PID: 12796|OmniSharp.Stdio.Host) ************ Request ************
{
  "Command": "/completion",
  "Seq": 196,
  "Arguments": {
    "CompletionTrigger": 1,
    "TriggerCharacter": null,
    "Line": 1,
    "Column": 25,
    "Buffer": null,
    "Changes": null,
    "ApplyChangesTogether": false,
    "FileName": "C:\\Users\\user\\AppData\\Local\\Temp\\NetPad\\OmniSharp\\a67e5ebc-61d3-4003-ac8a-ded77e8a0bb5\\User_Program.cs"
  }
}
2024-07-11T14:22:38.9940693-04:00 [ERR] (PID: 12796|OmniSharp.Stdio.Host) ************  Response (20.2601ms) ************ 
{
  "Request_seq": 196,
  "Command": "/completion",
  "Running": true,
  "Success": false,
  "Message": "\"System.IndexOutOfRangeException: Index was outside the bounds of the array.\\r\\n   at Microsoft.CodeAnalysis.Text.StringText.get_Item(Int32 position)\\r\\n   at Microsoft.CodeAnalysis.Completion.CommonCompletionUtilities.GetWordSpan(SourceText text, Int32 position, Func`2 isWordStartCharacter, Func`2 isWordCharacter, Boolean alwaysExtendEndSpan)\\r\\n   at Microsoft.CodeAnalysis.Completion.CommonCompletionUtilities.GetWordSpan(SourceText text, Int32 position, Func`2 isWordStartCharacter, Func`2 isWordCharacter)\\r\\n   at Microsoft.CodeAnalysis.CSharp.Completion.Providers.CompletionUtilities.GetCompletionItemSpan(SourceText text, Int32 position)\\r\\n   at Microsoft.CodeAnalysis.CSharp.Completion.CSharpCompletionService.GetDefaultCompletionListSpan(SourceText text, Int32 caretPosition)\\r\\n   at Microsoft.CodeAnalysis.Completion.CompletionService.GetCompletionsAsync(Document document, Int32 caretPosition, CompletionOptions options, OptionSet passThroughOptions, CompletionTrigger trigger, ImmutableHashSet`1 roles, CancellationToken cancellationToken)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService.Handle(CompletionRequest request, Boolean forceExpandedCompletionIndexCreation) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Completion\\\\CompletionService.cs:line 95\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 200\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 229\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 130\\r\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"",
  "Body": null,
  "Seq": 242,
  "Type": "response"
}
2024-07-11T14:22:41.1894018-04:00 [WRN] (PID: 12796|OmniSharp.Stdio.Host) ************ Request ************
{
  "Command": "/completion",
  "Seq": 218,
  "Arguments": {
    "CompletionTrigger": 1,
    "TriggerCharacter": null,
    "Line": 1,
    "Column": 28,
    "Buffer": null,
    "Changes": null,
    "ApplyChangesTogether": false,
    "FileName": "C:\\Users\\user\\AppData\\Local\\Temp\\NetPad\\OmniSharp\\a67e5ebc-61d3-4003-ac8a-ded77e8a0bb5\\User_Program.cs"
  }
}
2024-07-11T14:22:41.1897958-04:00 [ERR] (PID: 12796|OmniSharp.Stdio.Host) ************  Response (15.4087ms) ************ 
{
  "Request_seq": 218,
  "Command": "/completion",
  "Running": true,
  "Success": false,
  "Message": "\"System.IndexOutOfRangeException: Index was outside the bounds of the array.\\r\\n   at Microsoft.CodeAnalysis.Text.StringText.get_Item(Int32 position)\\r\\n   at Microsoft.CodeAnalysis.Completion.CommonCompletionUtilities.GetWordSpan(SourceText text, Int32 position, Func`2 isWordStartCharacter, Func`2 isWordCharacter, Boolean alwaysExtendEndSpan)\\r\\n   at Microsoft.CodeAnalysis.Completion.CommonCompletionUtilities.GetWordSpan(SourceText text, Int32 position, Func`2 isWordStartCharacter, Func`2 isWordCharacter)\\r\\n   at Microsoft.CodeAnalysis.CSharp.Completion.Providers.CompletionUtilities.GetCompletionItemSpan(SourceText text, Int32 position)\\r\\n   at Microsoft.CodeAnalysis.CSharp.Completion.CSharpCompletionService.GetDefaultCompletionListSpan(SourceText text, Int32 caretPosition)\\r\\n   at Microsoft.CodeAnalysis.Completion.CompletionService.GetCompletionsAsync(Document document, Int32 caretPosition, CompletionOptions options, OptionSet passThroughOptions, CompletionTrigger trigger, ImmutableHashSet`1 roles, CancellationToken cancellationToken)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService.Handle(CompletionRequest request, Boolean forceExpandedCompletionIndexCreation) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Completion\\\\CompletionService.cs:line 95\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 200\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 229\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 130\\r\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"",
  "Body": null,
  "Seq": 296,
  "Type": "response"
}

Just to add a little bit more of context if it matters. I'm creating a new script with the following settings:

rkttu commented 4 months ago

This seems to be a problem that occurs when upgrading to a new version while using an older version. I wanted to restore functionality right away, so I deleted the Application Data directory and ran NetPad again to confirm that IntelliSense was working normally again.

rkttu commented 4 months ago

However, after changing the settings and referencing the NuGet package that I use every day, the problem occurred again. I'm also attaching the log file and App Data directory for verification.

https://1drv.ms/u/s!Aj231qrFhIQxquxS-y7B0bzmll4GKQ?e=YtWeyR

Log File: log20240712.txt

I tested the NetPad v0.7.2 on the Apple M2 macbook Air (macOS Sonoma 14.5)

tareqimbasher commented 4 months ago

Thank you for that info, I will take a look!

tareqimbasher commented 1 month ago

@rkttu @ThunderCls can you try the new version and let me know if you're still seeing the same problem? Thank you

rkttu commented 1 month ago

Hmm... Since it's been a while since I ran it, I deleted the existing data directory, then replace the existing app with new app, and ran it, but it seems like the IntelliSense feature has more limitations than before. (IntelliSense for local variables is barely usable, and appears to be available only to the extent of hinting for well-known static methods like Console.WriteLine.)

I'm recording the current situation and uploading it as a video.

https://github.com/user-attachments/assets/f115d6c6-abf7-4b88-9b89-cf37fafab98f

bbilginn commented 2 days ago

Same here :(

image image