PowerShell / PowerShell/PowerShellEditorServices

ArgumentOutOfRangeException in ValidatePosition

Open
#870 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Workspaces Issue-Bug
Dominant language
C#
Stars
767
Forks
266
Avg merge
3d 16h
Merged PRs (30d)
1

Description

Still getting this exception in 1.11.0 version of the extension in v1.31.1 of VSCode.

2019-02-23 22:10:41.702 [VERBOSE] tid:17 in 'ResolveFilePath' C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: line 466
    Resolved path: c:\Users\Keith\GitHub\dahlbyk\posh-git\src\GitUtils.ps1

2019-02-23 22:10:41.888 [ERROR] tid:43 in 'OnListenTaskCompleted' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Specified argument was out of the range of valid values.
    Parameter name: Position 569:64 is outside of the line range of 1 to 497.) ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 569:64 is outside of the line range of 1 to 497.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 569:64 is outside of the line range of 1 to 497.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

vscode-powershell.zip

This happened when I was pasting some text in the middle of the file.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition and ApplyChange, then trace the call from LanguageServer.HandleDidChangeTextDocumentNotification. Reproduce the reported paste operation in VSCode using the supplied logs and archive; done means the change no longer terminates the protocol message loop with an ArgumentOutOfRangeException.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell, vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.