Skip to content

Commit 85595cd

Browse files
committed
Mouse wheel doesn't work with powershell console
Fix is to clear the flag for capturing mouse events while in PSReadline because we would ignore them anyway.
1 parent f4ee589 commit 85595cd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

PSReadLine/ConsoleLib.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public static class NativeMethods
2424

2525
public const uint ENABLE_PROCESSED_INPUT = 0x0001;
2626
public const uint ENABLE_LINE_INPUT = 0x0002;
27+
public const uint ENABLE_WINDOW_INPUT = 0x0008;
28+
public const uint ENABLE_MOUSE_INPUT = 0x0010;
2729

2830
public const int FontTypeMask = 0x06;
2931
public const int TrueTypeFont = 0x04;

PSReadLine/ReadLine.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,15 @@ public static string ReadLine(Runspace remoteRunspace = null, EngineIntrinsics e
258258
// Clear a couple flags so we can actually receive certain keys:
259259
// ENABLE_PROCESSED_INPUT - enables Ctrl+C
260260
// ENABLE_LINE_INPUT - enables Ctrl+S
261-
NativeMethods.SetConsoleMode(handle,
262-
_singleton._prePSReadlineConsoleMode & ~(NativeMethods.ENABLE_PROCESSED_INPUT | NativeMethods.ENABLE_LINE_INPUT));
261+
// Also clear a couple flags so we don't mask the input that we ignore:
262+
// ENABLE_MOUSE_INPUT - mouse events
263+
// ENABLE_WINDOW_INPUT - window resize events
264+
var mode = _singleton._prePSReadlineConsoleMode &
265+
~(NativeMethods.ENABLE_PROCESSED_INPUT |
266+
NativeMethods.ENABLE_LINE_INPUT |
267+
NativeMethods.ENABLE_WINDOW_INPUT |
268+
NativeMethods.ENABLE_MOUSE_INPUT);
269+
NativeMethods.SetConsoleMode(handle, mode);
263270

264271
_singleton.Initialize(remoteRunspace, engineIntrinsics);
265272
return _singleton.InputLoop();

0 commit comments

Comments
 (0)