PowerShell / PowerShell/vscode-powershell

InsertText method inserts lone carriage return characters as new lines.

Open
#5,524 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-psEditor Issue-Bug OS-Windows
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce

  1. Open a existing script file with CRLF end of line sequence.

  2. Move cursor to the end of the file.

  3. In the integrated console run

$chars = $psEditor.GetEditorContext().CurrentFile.GetText().ToCharArray()

$chars.ForEach{
    $psEditor.GetEditorContext().CurrentFile.InsertText($PSItem)
    Start-Sleep -Milliseconds 50
}

The file will be reproduced character by character, but with double lines.

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

Reproduce the issue by opening a CRLF script, moving to the end, and running the provided PowerShell snippet in the integrated console. Start by tracing the InsertText behavior used by CurrentFile; done means reproducing the file character by character without lone carriage returns creating extra lines.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.