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

Output is invisible when run under PowerShell Core #10

Closed
crasshacker opened this issue Jun 14, 2019 · 14 comments · Fixed by #26
Closed

Output is invisible when run under PowerShell Core #10

crasshacker opened this issue Jun 14, 2019 · 14 comments · Fixed by #26

Comments

@crasshacker
Copy link

When executed within a PowerShell Core console (the open source version of PowerShell that runs on Windows, Linux, and MacOS X), less works properly except that the output is invisible. That is, the console area where the text should be displayed is blank, but it's clear (e.g., by navigating up and down using the j/k keys and the = key to see what section of the file is being displayed) that the program itself is behaving correctly in all other ways. This problem only occurs when running under PowerShell Core; it does not occur when running under Windows PowerShell. I have not tested this on PowerShell Core running on either Linux or MacOS.

@jimfoltz
Copy link

jimfoltz commented Aug 4, 2019

I see this also on Windows 10 using cmd.exe in the new Terminal console host, although

For example, I generate some functions names like this:

>lib\sketchup_ffi.rb | grep  model_get
model_get_active_scene
model_get_all_materials
model_get_attribute_dictionaries
...

But screen is blank when piped to less:
>lib\sketchup_ffi.rb | grep model_get | less

less help screen then looks like this:

00577

I have always set LESSCHARSET=utf-8 environmental variable.

Thank you for maintaining this software for Windows.

@rivy
Copy link

rivy commented Aug 12, 2019

I encountered this problem as well for Windows 10.

If it's the same problem, I have a fix in the 'dev' branch of my fork (rivy/less).

Once I finish testing it, I'll be merging that branch into master.

It might be a workaround for you until this is resolved within this repository.

@jimfoltz
Copy link

Thanks @rivy, I'll try your dev branch.

@rivy
Copy link

rivy commented Aug 15, 2019

@jimfoltz ,

I just pushed the 'dev' branch to my fork's 'master' and tagged it as a point release (https://github.com/rivy/less/releases/tag/v530.2).

It looks good to me for CMD or PowerShell, with both the default console host and wt (the new Windows Terminal).

Let me know if it fixes you're problem.

@gwsw
Copy link
Owner

gwsw commented Aug 18, 2019

@rivy, your fix checks whether the window foreground and background colors are set to the same color, and forces them to be different if so. But why would the colors be the same in the first place? I assume this isn't just a user error where someone deliberately set the colors to be the same.

@rivy
Copy link

rivy commented Aug 18, 2019

I believe it's a console bug for Windows 10. Unfortunately, I've not been able to hone in any further on the error. And since I'm not sure where it's really coming from or why, I haven't filed a bug report.

I only noticed that it started happening after I upgraded from one Win10 version to another. And I'm not purposefully setting the foreground and background to the same color, 😄.

Yes, the "fix" is really only a heuristic repair, but I think it's a benign change as I can't think of a reason why anyone would run less intentionally with background == foreground.

@jimfoltz
Copy link

I have not found a consistent way to reproduce this. I can often reproduce this using ripgrep and less. By running rg without less, followed by running rg with less I frequently get a blank screen, but not always.

> rg enum

followed by
> rg enum | less

I can sometimes get back to normal using some combination of color and cls but not always.

@gwojan
Copy link

gwojan commented Sep 17, 2019

I believe it's a console bug for Windows 10. Unfortunately, I've not been able to hone in any further on the error. And since I'm not sure where it's really coming from or why, I haven't filed a bug report.

It's definitely a bug with with Windows 10 1903 conhost... It's easily reproduced in the legacy conhost.exe and wt.exe with powershell.exe and pwsh.exe. I can't seem to reproduce it with cmd.exe though.

One thing I have noticed is if I do a clear screen first and then less somefile the contents are displayed properly.

@lzybkr
Copy link
Contributor

lzybkr commented Oct 15, 2019

I've shared a build with my fix for this issue and another (24 bit color support not working correctly on Windows 10) here.

@gwojan
Copy link

gwojan commented Oct 15, 2019

Thanks @lzybkr! Your fix works great!

@rivy
Copy link

rivy commented Oct 16, 2019

Thanks, @lzybkr.
I've also incorporated your fix into my fork's main line (v550.1).

@lzybkr
Copy link
Contributor

lzybkr commented Oct 16, 2019

@rivy - you probably want to pick up lzybkr@163de2d as well. My change improves on rivy/less@24f137a by working when you pass --no-init which is important as git uses that option.

@gwsw gwsw closed this as completed in #26 Oct 17, 2019
@xa0082249956
Copy link

I believe it's a console bug for Windows 10. Unfortunately, I've not been able to hone in any further on the error. And since I'm not sure where it's really coming from or why, I haven't filed a bug report.

It's definitely a bug with with Windows 10 1903 conhost... It's easily reproduced in the legacy conhost.exe and wt.exe with powershell.exe and pwsh.exe. I can't seem to reproduce it with cmd.exe though.

One thing I have noticed is if I do a clear screen first and then less somefile the contents are displayed properly.

less version 551 installed from chocolatey. The problem still occurs.
image.png

@rivy
Copy link

rivy commented Nov 4, 2019

@lzybkr

@rivy - you probably want to pick up lzybkr@163de2d as well. My change improves on rivy/less@24f137a by working when you pass --no-init which is important as git uses that option.

Thanks for the suggestion. I'll look at integrating a modification of the original commit.

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

Successfully merging a pull request may close this issue.

7 participants