Xterm.js: node-pty terminals jump to bottom when a .NET Core console app requests for a cursor position

Created on 24 Jul 2018  路  11Comments  路  Source: xtermjs/xterm.js

_From @tylerl0706 on July 21, 2018 3:13_

Environment

  • Environment: VSCode and Hyper
  • OS version: macOS & Fedora 28

Details

node-pty terminals jump to the bottom when a .NET Core console app requests for a cursor position. In other terminals (iterm, terminal.app), it does not.

This only happens on unix/linux OS's - Windows works as expected.

This is easily reproducible in PowerShell since it's built on .NET Core.

Steps to reproduce

  1. have PowerShell on unix
  2. hit enter a bunch (until the page starts scrolling)
  3. run this
while ($true) { $null = [Console]::CursorTop; Start-Sleep 1 }
  1. scroll up

Note the use of [Console]::CursorTop which is the cursor query. In .NET Core, this emits the report cursor position ansi escape sequence on unix-like platforms

Actual behavior

The console window jumps down to the prompt

Expected behavior

The console window does not move

_Copied from original issue: Microsoft/node-pty#211_

help wanted typbug

Most helpful comment

@tylerl0706 can you clone my fork, checkout 1579_emit_pos_directly and test if this fixes it by running the demo?

All 11 comments

p.s. @Tyriar is awesome 馃憤

_From @jerch on July 23, 2018 16:14_

@tylerl0706 Imho this can't be fixed in the pty binding, the binding simply routes the byte streams to and from the OS into JS space. This seems more emulator related (if you use xterm.js as emulator - thats the place to address this imho).

Ah my bad - that's my lack of knowledge of the stack. I can move this over there if you'd like

_From @Tyriar on July 23, 2018 17:45_

This is happening because the text is sent via Terminal.send:

https://github.com/xtermjs/xterm.js/blob/8f22d8dda4f282e6c10943576ed5797317ad626f/src/InputHandler.ts#L1717-L1724

https://github.com/xtermjs/xterm.js/blob/8f22d8dda4f282e6c10943576ed5797317ad626f/src/Terminal.ts#L1814-L1817

I'm not totally sure what the right behavior is (I would check other terminals), but it definitely belongs in xterm.js 馃憤

We should check what the behavior of other popular linux/mac terminals is when you're in the scrollback and cursor position is requested, if we're doing standard behavior I'm not sure how best to fix this for PS atm.

@Tyriar not sure if you over looked it - but in the description I mentioned that this behavior is different from within iTerm2 and Terminal.app (2 non-xtermjs terminals) on macOS. It doesn't scroll back.

@tylerl0706 oh ok, I thought this was a PS extension within VS Code thing.

@tylerl0706 can you clone my fork, checkout 1579_emit_pos_directly and test if this fixes it by running the demo?

@Tyriar sorry for the delay! I was heads down on OneWeek 馃憤

I can confirm that branch fixes the problem 馃帀

@tylerl0706 I pulled the fix into VS Code, you can test it there on Monday

Was this page helpful?
0 / 5 - 0 ratings

Related issues

albinekb picture albinekb  路  4Comments

jestapinski picture jestapinski  路  3Comments

circuitry2 picture circuitry2  路  4Comments

Tyriar picture Tyriar  路  4Comments

jerch picture jerch  路  3Comments