-
Notifications
You must be signed in to change notification settings - Fork 69
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
fix(cli-repl): support bracketed paste on Windows MONGOSH-1999 #2338
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
scripts/nodejs-patches/006-windows-virtual-terminal-input-libuv-4688.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c | ||
index 7e1f15544b17..37bc2c4ace57 100644 | ||
--- a/deps/uv/src/win/tty.c | ||
+++ b/deps/uv/src/win/tty.c | ||
@@ -58,6 +58,9 @@ | ||
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING | ||
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 | ||
#endif | ||
+#ifndef ENABLE_VIRTUAL_TERMINAL_INPUT | ||
+#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200 | ||
+#endif | ||
|
||
#define CURSOR_SIZE_SMALL 25 | ||
#define CURSOR_SIZE_LARGE 100 | ||
@@ -344,6 +347,7 @@ static void uv__tty_capture_initial_style( | ||
|
||
int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { | ||
DWORD flags; | ||
+ DWORD try_set_flags; | ||
unsigned char was_reading; | ||
uv_alloc_cb alloc_cb; | ||
uv_read_cb read_cb; | ||
@@ -360,9 +364,11 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { | ||
switch (mode) { | ||
case UV_TTY_MODE_NORMAL: | ||
flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT; | ||
+ try_set_flags = 0; | ||
break; | ||
case UV_TTY_MODE_RAW: | ||
flags = ENABLE_WINDOW_INPUT; | ||
+ try_set_flags = ENABLE_VIRTUAL_TERMINAL_INPUT; | ||
break; | ||
case UV_TTY_MODE_IO: | ||
return UV_ENOTSUP; | ||
@@ -386,7 +392,10 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { | ||
} | ||
|
||
uv_sem_wait(&uv_tty_output_lock); | ||
- if (!SetConsoleMode(tty->handle, flags)) { | ||
+ if ( | ||
+ !SetConsoleMode(tty->handle, flags | try_set_flags) && | ||
+ !SetConsoleMode(tty->handle, flags) | ||
+ ) { | ||
err = uv_translate_sys_error(GetLastError()); | ||
uv_sem_post(&uv_tty_output_lock); | ||
return err; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the significance of the 0x0200 value? is it just an available value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can look up the values here: https://learn.microsoft.com/en-us/windows/console/setconsolemode#parameters
This
#define
, like the one above, is added in case the compilation happens on a Windows machine that doesn't have the most recent system headers and doesn't know about the flag yet, so you can still compile a program that can make use of it when run on more recent Windows machines.That's not a practical concern for mongosh, but for the libuv PR it's relevant.