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

compiler, when it watch mode, resets the screen colors #29829

Open
emmanueltouzery opened this issue Feb 8, 2019 · 4 comments
Open

compiler, when it watch mode, resets the screen colors #29829

emmanueltouzery opened this issue Feb 8, 2019 · 4 comments
Labels
Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Milestone

Comments

@emmanueltouzery
Copy link

TypeScript Version: 3.4.0-dev.20190208

Search Terms: terminal, watcher

Issue

I'm using linux, and I have a custom terminal theme (I'm using powerlevel-9k). To make it look more pleasing, I tuned the terminal colors, but I did that through tput commands in my .zshrc:

tput initc 0 172 196 200
tput initc 1 800 210 100
tput initc 2 220 560 220
tput initc 3 800 460 180
tput initc 4 350 530 670
tput initc 5 630 380 470
tput initc 6 470 710 760
tput initc 7 810 810 810
tput initc 8 570 570 570
tput initc 9 1000 280 200
tput initc 10 720 710 0
tput initc 11 1000 780 430
tput initc 12 530 760 1000
tput initc 13 820 820 1000
tput initc 14 440 760 830
tput initc 15 910 910 910

I am loosing these customizations if I run typescript's compiler tsc in watch mode (tsc -w) and exit it through ctrl-c. When returning to the shell after that, the colors are the original ones, as if the tput commands were never executed. So it seems tsc -w is sending a too drastic reset command to the terminal, which does not only erase tsc's output but can also discard some user's customizations to their terminal.

Notice that the issue occurs with the xterm and kitty terminals, but NOT with gnome-terminal, which seems to be a gnome-terminal or vte bug (see kitty bug and vte bug).

Expected behavior:
Running and exiting tsc -w shouldn't discard my color customizations to my terminal.

Actual behavior:
Running and exiting tsc -w discards my color customizations to my terminal.

Note that when searching if that bug was already reported, I stumbled upon the --preserveWatchOutput flag and I can confirm that when this flag is enabled, the issue is NOT present.

@DanielRosenwasser DanielRosenwasser added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Help Wanted You can do this Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". labels Feb 8, 2019
@DanielRosenwasser
Copy link
Member

I've hit this, but it's not only tsc that runs into this. I guess we can try to intercept SIGINT and send a color reset code? Seems nasty in the current system though. @Tyriar might also know more here.

@egmontkob
Copy link

As per the VTE investigation, it's an ESC c emitted at startup that reverts the palette.

I guess we can try to intercept SIGINT and send a color reset code?

What Emmanual is asking for is not to emit such codes.

@textshell
Copy link

textshell commented Feb 9, 2019

https://github.com/Microsoft/TypeScript/blob/master/src/compiler/sys.ts#L668

                clearScreen: () => {
                    process.stdout.write("\x1Bc");
                },

But that code is reset. It should be Erase Display Complete aka \x1B[2J

@orta
Copy link
Contributor

orta commented Jul 15, 2019

I took a quick stab at using "\x1Bc" but it had weird behavior, where it wouldn't reset back to up to the top, but clear and continue.

just-first 2019-07-15 11_32_38

Adding both:

      clearScreen: () => {
                    process.stdout.write('\x1b[0f');
                    process.stdout.write("\x1B[2J");
                },

which I saw in node-clear would always skip the first line too.

This is unlikely a quick fix.

@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants