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

New Line Mode does not work when use PSFzf #18263

Open
mrbeardad opened this issue Nov 29, 2024 · 3 comments
Open

New Line Mode does not work when use PSFzf #18263

mrbeardad opened this issue Nov 29, 2024 · 3 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@mrbeardad
Copy link

Windows Terminal version

1.21.3231.0

Windows build number

10.0.22631.0

Other Software

PowerShell 7.4.6
PSFzf 2.6.7

Steps to reproduce

Install PSFzf by Import-Module PSFzf, then set the content of powershell $PROFILE to following

Set-PSReadLineKeyHandler -Key Tab -ScriptBlock {
  Invoke-FzfTabCompletion
}
return
  1. type any command ant press tab to complete until the bug appear
  2. it seams like "new line mode" does not work well, outputing "`e[20h" to enable "newline mode" could fix this, but not always
newlinemode.mp4

Expected Behavior

"`e[20h" set to "newline mode"

Actual Behavior

still in "linefeed mode"

@mrbeardad mrbeardad added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Nov 29, 2024
@j4james
Copy link
Collaborator

j4james commented Nov 30, 2024

What you're seeing is most likely the result of the console mode DISABLE_NEWLINE_AUTO_RETURN rather than the ANSI newline mode 20. There is an open issue for fzf that suggests they may be setting the mode but not always cleaning up afterwards. See junegunn/fzf#3334

@mrbeardad
Copy link
Author

I'm not sure about this, but it seems DISABLE_NEWLINE_AUTO_RETURN (0x0008) is unset.

#include <iostream>
#include <windows.h>

int main(int argc, char* argv[])
{
  auto ih = GetStdHandle(STD_INPUT_HANDLE);
  DWORD mode = 0;
  GetConsoleMode(ih, &mode);
  std::cout << "stdin mode: 0x" << std::hex << mode << std::endl;
  auto oh = GetStdHandle(STD_OUTPUT_HANDLE);
  mode = 0;
  GetConsoleMode(oh, &mode);
  std::cout << "stdout mode: 0x" << std::hex << mode << std::endl;
}

Image

@mrbeardad
Copy link
Author

I got console mode as 0xf by the code in the junegunn/fzf#3334, I don't understand why it is different than native code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

2 participants