Cannot scroll up after couple time open and exit neovim #22111

Closed
opened 2026-01-31 08:03:44 +00:00 by claunia · 4 comments
Owner

Originally created by @radiaku on GitHub (Aug 19, 2024).

Windows Terminal version

1.20.11781.0

Windows build number

10.0.22631.4037

Other Software

Neovim 0.10.1
Powershell 7.4.4
oh-my-posh 23.6.3

Steps to reproduce

Opening nvim editing file multiple file, exit. then running nvim and then exit. couple times. I can scroll up but its become scroll history

Expected Behavior

scroll to up screen

Actual Behavior

becoming scroll up command line ( history )

check the video,

https://github.com/user-attachments/assets/009224fe-a452-401f-b9d9-b087126fcff6

this my $profile

Set-Alias -Name nvimq -Value "C:\neovimqt\bin\nvim-qt.exe"


function wtd { wt -d . }

# touch
function touch ($command) {
    New-Item -Path $command -ItemType File | out-null && Write-Host Created $command
}

function rm ($command) {
    Remove-Item $command -Recurse && Write-Host Removed $command
}

## $Env:PATH management
Function Add-DirectoryToPath {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
        [Alias("FullName")]
        [string] $path,
        [string] $variable = "PATH",

        [switch] $clear,
        [switch] $force,
        [switch] $prepend,
        [switch] $whatIf
    )

    BEGIN {

        ## normalize paths

        $count = 0
        $paths = @()

        if (-not $clear.IsPresent) {

            $environ = Invoke-Expression "`$Env:$variable"
            $environ.Split(";") | ForEach-Object {
                if ($_.Length -gt 0) {
                    $count = $count + 1
                    $paths += $_.ToLowerInvariant()
                }
            }

            Write-Verbose "Currently $($count) entries in `$env:$variable"
        }

        Function Array-Contains {
            param(
                [string[]] $array,
                [string] $item
            )

            $any = $array | Where-Object -FilterScript {
                $_ -eq $item
            }

            Write-Output ($null -ne $any)
        }
    }

    PROCESS {

        if ([IO.Directory]::Exists($path) -or $force.IsPresent) {

            $path = $path.Trim()

            $newPath = $path.ToLowerInvariant()
            if (-not (Array-Contains -Array $paths -Item $newPath)) {
                if ($whatIf.IsPresent) {
                    Write-Host $path
                }

                if ($prepend.IsPresent) { $paths = , $path + $paths }
                else { $paths += $path }

                Write-Verbose "Adding $($path) to `$env:$variable"
            }
        }
        else {

            Write-Host "Invalid entry in `$Env:$($variable): ``$path``" -ForegroundColor Yellow

        }
    }

    END {

        ## re-create PATH environment variable

        $separator = [IO.Path]::PathSeparator
        $joinedPaths = [string]::Join($separator, $paths)

        if ($whatIf.IsPresent) {
            Write-Output $joinedPaths
        }
        else {
            Invoke-Expression " `$env:$variable = `"$joinedPaths`" "
        }
    }

}

. oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\amro.omp.json" | Invoke-Expression

Import-Module Terminal-Icons

Set-PSReadLineOption -BellStyle None

Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

function ll {
    Get-ChildItem $Args[0] |
        Format-Table Mode, @{N='Owner';E={(Get-Acl $_.FullName).Owner}}, Length, LastWriteTime, @{N='Name';E={if($_.Target) {$_.Name+' -> '+$_.Target} else {$_.Name}}}
}

function whereis ($command) {
    Get-Command -Name $command -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}

function reloadprofile {
    @(
        $Profile.AllUsersAllHosts,
        $Profile.AllUsersCurrentHost,
        $Profile.CurrentUserAllHosts,
        $Profile.CurrentUserCurrentHost
    ) | % {
        if(Test-Path $_){
            Write-Verbose "Running $_"
            . $_
        }
    }
}

Originally created by @radiaku on GitHub (Aug 19, 2024). ### Windows Terminal version 1.20.11781.0 ### Windows build number 10.0.22631.4037 ### Other Software Neovim 0.10.1 Powershell 7.4.4 oh-my-posh 23.6.3 ### Steps to reproduce Opening nvim editing file multiple file, exit. then running nvim and then exit. couple times. I can scroll up but its become scroll history ### Expected Behavior scroll to up screen ### Actual Behavior becoming scroll up command line ( history ) check the video, https://github.com/user-attachments/assets/009224fe-a452-401f-b9d9-b087126fcff6 this my $profile ``` Set-Alias -Name nvimq -Value "C:\neovimqt\bin\nvim-qt.exe" function wtd { wt -d . } # touch function touch ($command) { New-Item -Path $command -ItemType File | out-null && Write-Host Created $command } function rm ($command) { Remove-Item $command -Recurse && Write-Host Removed $command } ## $Env:PATH management Function Add-DirectoryToPath { [CmdletBinding()] param( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [Alias("FullName")] [string] $path, [string] $variable = "PATH", [switch] $clear, [switch] $force, [switch] $prepend, [switch] $whatIf ) BEGIN { ## normalize paths $count = 0 $paths = @() if (-not $clear.IsPresent) { $environ = Invoke-Expression "`$Env:$variable" $environ.Split(";") | ForEach-Object { if ($_.Length -gt 0) { $count = $count + 1 $paths += $_.ToLowerInvariant() } } Write-Verbose "Currently $($count) entries in `$env:$variable" } Function Array-Contains { param( [string[]] $array, [string] $item ) $any = $array | Where-Object -FilterScript { $_ -eq $item } Write-Output ($null -ne $any) } } PROCESS { if ([IO.Directory]::Exists($path) -or $force.IsPresent) { $path = $path.Trim() $newPath = $path.ToLowerInvariant() if (-not (Array-Contains -Array $paths -Item $newPath)) { if ($whatIf.IsPresent) { Write-Host $path } if ($prepend.IsPresent) { $paths = , $path + $paths } else { $paths += $path } Write-Verbose "Adding $($path) to `$env:$variable" } } else { Write-Host "Invalid entry in `$Env:$($variable): ``$path``" -ForegroundColor Yellow } } END { ## re-create PATH environment variable $separator = [IO.Path]::PathSeparator $joinedPaths = [string]::Join($separator, $paths) if ($whatIf.IsPresent) { Write-Output $joinedPaths } else { Invoke-Expression " `$env:$variable = `"$joinedPaths`" " } } } . oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\amro.omp.json" | Invoke-Expression Import-Module Terminal-Icons Set-PSReadLineOption -BellStyle None Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward function ll { Get-ChildItem $Args[0] | Format-Table Mode, @{N='Owner';E={(Get-Acl $_.FullName).Owner}}, Length, LastWriteTime, @{N='Name';E={if($_.Target) {$_.Name+' -> '+$_.Target} else {$_.Name}}} } function whereis ($command) { Get-Command -Name $command -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue } function reloadprofile { @( $Profile.AllUsersAllHosts, $Profile.AllUsersCurrentHost, $Profile.CurrentUserAllHosts, $Profile.CurrentUserCurrentHost ) | % { if(Test-Path $_){ Write-Verbose "Running $_" . $_ } } } ```
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 08:03:44 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Aug 19, 2024):

So, I can't see the scrollbar in that video, but my psychic debugging is telling me that you're still in alternate scroll mode for some reason. That's a special mode where mouse wheels send up and down keystrokes instead of mouse wheel events. But it's only supposed to be active when in the "alternate screen buffer" (which is used by full screen apps like vim).

You could probably check that easily on your side by seeing if there's a scrollbar enabled in the "main" buffer after exiting nvim

@zadjii-msft commented on GitHub (Aug 19, 2024): So, I can't see the scrollbar in that video, but my psychic debugging is telling me that you're still in alternate scroll mode for some reason. That's a special mode where mouse wheels send up and down keystrokes instead of mouse wheel events. But it's only supposed to be active when in the "alternate screen buffer" (which is used by full screen apps like `vim`). You could probably check that easily on your side by seeing if there's a scrollbar enabled in the "main" buffer after exiting nvim
Author
Owner

@radiaku commented on GitHub (Aug 19, 2024):

Hello @zadjii-msft , I think this is true. I still cant replicate that, if not long run on nvim.

Btw if in case I still on alternate scroll mode after exiting nvim. can

How I can exit ( disable ) it?
maybe adding some function on $profile ?? or any function that help?

Update:
Yeah true the scrollbar is not showing

https://github.com/user-attachments/assets/bc841ba1-972a-44ee-8dd4-1ca0171c1e1a

@radiaku commented on GitHub (Aug 19, 2024): Hello @zadjii-msft , I think this is true. I still cant replicate that, if not long run on nvim. Btw if in case I still on alternate scroll mode after exiting nvim. can How I can exit ( disable ) it? maybe adding some function on $profile ?? or any function that help? Update: Yeah true the scrollbar is not showing https://github.com/user-attachments/assets/bc841ba1-972a-44ee-8dd4-1ca0171c1e1a
Author
Owner

@j4james commented on GitHub (Aug 19, 2024):

@radiaku If you're using PowerShell, you should be able to get the terminal to return to the main buffer by entering this at the prompt:

"`e[?1049l"

Once you're back in the main buffer the scrollbar should appear again, and the mouse wheel should work as you expect.

@j4james commented on GitHub (Aug 19, 2024): @radiaku If you're using PowerShell, you should be able to get the terminal to return to the main buffer by entering this at the prompt: ``` "`e[?1049l" ``` Once you're back in the main buffer the scrollbar should appear again, and the mouse wheel should work as you expect.
Author
Owner

@radiaku commented on GitHub (Aug 19, 2024):

@j4james , Thanks for your help. its working like a charm.

For short I create this function on $PROFILE and call cas for short.

function cas {
  # Clear Alternate Screen
  # https://github.com/microsoft/terminal/issues/17739
  [System.Console]::Write("`e[?1049l")
}

I leave this one on here if anybody need this.

@radiaku commented on GitHub (Aug 19, 2024): @j4james , Thanks for your help. its working like a charm. For short I create this function on $PROFILE and call _cas_ for short. ``` function cas { # Clear Alternate Screen # https://github.com/microsoft/terminal/issues/17739 [System.Console]::Write("`e[?1049l") } ``` I leave this one on here if anybody need this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22111