Skip to content
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

End of line not interpreted in powershell on linux #564

Open
MFreeze opened this issue Apr 11, 2024 · 2 comments
Open

End of line not interpreted in powershell on linux #564

MFreeze opened this issue Apr 11, 2024 · 2 comments

Comments

@MFreeze
Copy link

MFreeze commented Apr 11, 2024

Hi,

I'm using toggle-term without any issues on linux for zsh, bash, python, ...

However when using it with powershell on linux i'm encountering the following issue. I have the following powershell script:

Param (
  [Parameter(Mandatory, Position = 0)]
  [string] $Source,
  [Parameter(Mandatory, Position = 1)]
  [string] $Target
)

Function Test-Container {
  If (Test-Path $Args[0] -PathType Container) { Return $True }
  Else { Return $False }
}

Get-ChildItem -Path $Source -Recurse | ForEach-Object {
  $sourceFileName = $_.FullName
  $targetFileName = $_.FullName.Replace($Source, $Target)

  If (Test-Container $PSItem) {
    If (-not (Test-Path $targetFileName)) {
      Write-Host ("New folder {0}" -f $targetFileName) -ForegroundColor Yellow
      New-Item -Path $targetFileName -ItemType Directory | Out-Null
    }
  }

  Else {
    If (Test-Path $targetFileName) {
      $targetFile = Get-Item -Path $targetFileName
      If (($_.LastWriteTime -ne $targetFile.LastWriteTime) -or `
          ($_.Length -ne $targetFile.Length)) {
        Write-Host ("Modified file {0}" -f $sourceFileName) -ForegroundColor Red
        Copy-Item -Path $sourceFileName -Destination $targetFileName
      }
    }
    Else {
      Write-Host ("New file {0}" -f $sourceFileName) -ForegroundColor Green
      Copy-Item -Path $sourceFileName -Destination $targetFileName
    }
  }
}

Get-ChildItem -Path $Target -Recurse | ForEach-Object {
  If (-not (Test-Path $_.FullName.Replace($Target, $Source))) {
    Write-Host ("Extra {0} {1}" -f ((Test-Container $_) ? 'folder' : 'file'), `
        $_.FullName) -ForegroundColor Red
    Remove-Item -Path $_.FullName -Recurse
  }
}

I toggle my terminal as usual with ToggleTerm, launch a powershell interpreter into it with: pwsh -NoLogo. And then tries to send the whole file to the terminal using ToggleTermSendVisualLines. The whole is indeed sent to the terminal, but appears to be a one liner, in other terms I get the following result:

Param (  [Parameter(Mandatory, Position = 0)]  [string] $Source,  [Parameter(Mandatory, Position = 1)]  [string] $Target)Function Test-Container {  If (Test-Path $Args[0] -PathType Container) { Return $True }  Else { Return $False }}Get-ChildItem -Path $Source -Recurse | ForEach-Object {  $sourceFileName = $_.FullName  $targetFileName = $_.FullName.Replace($Source, $Target)  If (Test-Container $PSItem) {    If (-not (Test-Path $targetFileName)) {      Write-Host ("New folder {0}" -f $targetFileName) -ForegroundColor Yellow      New-Item -Path $targetFileName -ItemType Directory | Out-Null    }  }  Else {    If (Test-Path $targetFileName) {      $targetFile = Get-Item -Path $targetFileName      If (($_.LastWriteTime -ne $targetFile.LastWriteTime) -or `          ($_.Length -ne $targetFile.Length)) {        Write-Host ("Modified file {0}" -f $sourceFileName) -ForegroundColor Red        Copy-Item -Path $sourceFileName -Destination $targetFileName      }    }    Else {      Write-Host ("New file {0}" -f $sourceFileName) -ForegroundColor Green      Copy-Item -Path $sourceFileName -Destination $targetFileName    }  }}Get-ChildItem -Path $Target -Recurse | ForEach-Object {  If (-not (Test-Path $_.FullName.Replace($Target, $Source))) {    Write-Host ("Extra {0} {1}" -f ((Test-Container $_) ? 'folder' : 'file'), `        $_.FullName) -ForegroundColor Red    Remove-Item -Path $_.FullName -Recurse  }}

It seems that the ends of line are not interpreted when transfering content.

I'm running nvim 0.9.5 on arch linux.

@akinsho
Copy link
Owner

akinsho commented Apr 19, 2024

@MFreeze I do absolutely zero work ever with powershell and generally don't add any functionality or fix bugs around that. All the logic relating to this is user contributed. So will leave this open for a bit for Powershell Users to open PRs for it otherwise will have to declare bankruptcy if there are no takers

@MFreeze
Copy link
Author

MFreeze commented Apr 21, 2024

Fair enough ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants