224 Commits
Author SHA1 Message Date
spaette 486388c59f Fix some typos in this repository (#3547) 2023-01-23 14:22:59 -08:00
Dongbo Wang 2ef36fb77c Enable IntelliSense prediction by default (#3351) 2022-06-22 12:15:17 -07:00
Patrick Meinecke e94afef3a0 Sync ReadKeyProc thread with pipeline thread (#3294)
The pipeline thread was returning before the `ReadKeyProcThread` had finished processing the dummy input.
This was occurring somewhat frequently when `ReadLine` was invoked multiple times in a row creating a race condition.
With these changes, the pipeline thread will wait for dummy input to be received, dequeue the key, and continue with normal cancellation logic.
2022-04-27 10:56:26 -07:00
Dongbo Wang 703f7a4833 Update the cancellation related code (#3280) 2022-04-19 11:21:48 -07:00
Andy Schwartzmeyer 72edd4498b Respect cancellation in ReadOneOrMoreKeys() (#3274)
Because .NET's . `Console.ReadKey()` is uncancellable, when a hosting
application cancels PSReadLine, it also has to send a key press to get
`ReadKey` to return. In this case, we want to ignore the key press (and
a user certainly would not be expecting it, as `ReadLine` has already
been canceled).
2022-04-19 09:09:00 -07:00
Dongbo Wang f46f15d2d6 Improve RecomputeInitialCoords to be more robust and handle a couple special cases (#3074) 2022-01-03 16:40:25 -08:00
Dongbo Wang b76883665b Add BasicScrollingConsole to support test cases for scrolling up scenarios (#3081) 2021-12-14 15:14:03 -08:00
Dongbo Wang 835bfd2bf8 Skip the AST analysis when command-line input has any parsing errors (#3075) 2021-12-02 16:24:09 -08:00
Dongbo Wang e8b5d84a66 Disable warning for the private contract field with PSES (#2935) 2021-10-27 13:16:40 -07:00
Dongbo Wang cdc164ca4b Generate OnIdle event only if the editing buffer is empty (#2934) 2021-10-27 13:08:08 -07:00
Robert Holt 4e8c8a0ce9 Add private contract delegate for PSES to handle idle (#1679) 2021-10-27 11:31:08 -07:00
Dongbo Wang bc485e0208 Pass the cancellation token along instead of using the default one (#2636) 2021-07-01 16:10:11 -07:00
Dongbo Wang b2763825e4 Temporarily add back the API that is depended by PSES to avoid breaking changes (#2533) 2021-06-01 14:15:58 -07:00
Dongbo Wang f5a7ebda97 Update the use of the prediction interface to adapt to the breaking changes introduced in PowerShell 7.2.0-preview.6 (#2524) 2021-06-01 10:32:44 -07:00
Dongbo Wang 8df5b6ba08 Update PSReadLine corresponding to the prediction interface update (#2225) 2021-02-22 18:17:26 -08:00
Maxime Labelle 0de63689c4 Remove LineIsMultiline in favor of multi-line agnostic algorithms (#1125) (#2047) 2021-02-11 15:57:37 -08:00
Maxime Labelle 9d5b41f1f6 Refactor the usage of _clipboard (#2022) 2021-02-09 22:14:12 -08:00
Dongbo Wang fd1265e385 Add the prediction ListView and also hook up with the CommandPrediction APIs introduced in PS 7.1 (#1909) 2020-11-03 14:17:37 -08:00
Dongbo Wang 219ffa17c2 Allow MaximumHistoryCount to be set from user's profile (#1869) 2020-10-09 10:42:26 -07:00
Tyler James Leonhardt 88a21e484f Run script in local scope to make PSReadLine works in PSES in ConstrainedLanguageMode (#1527) 2020-05-14 16:58:52 -07:00
Dongbo Wang 5204b85852 Fix the env-data script and write buffer info in case of exception (#1482) 2020-04-21 10:21:10 -07:00
Dongbo Wang 03a0d3fe2b Name the ReadKey thread for debug purpose (#1313) 2020-01-23 11:40:37 -08:00
Dongbo Wang fd13554df8 Preserve and clear the saved current line properly (#1259)
1. Preserve the saved current line and the history index while in a series of history commands.
    So when switching between different history command, such as from `F8`/`Shift+F8` (`HistorySearchBackward` and `HistorySearchForward`) to `UpArrow`/`DownArrow`  (recall history) or from `Ctrl+r`/`Ctrl+s` to `UpArrow`/`DownArrow`, the history command can continue to work as expected.
2. Clear the saved current line when we are out of a series of history commands.
    So the saved line will not leak to another unrelated history search.
2020-01-01 22:44:46 -08:00
Maxime Labelle 9ad8eb6769 Ensure the desired column number is used while moving up or down in VI mode (#1122) 2019-12-09 13:48:14 -08:00
Jason Shirk 599e1784a9 Improve handling of color in prompts (#1180) 2019-11-25 12:59:09 -08:00
Maxime Labelle f25a089290 Supporting line wise yanks, including paste and undo. (#811) 2019-11-08 14:42:13 -08:00
Tyler James Leonhardt 65be868acd Fix for a nullref thrown when PSES calls ForcePSEventHandling (#1097) 2019-10-30 14:21:39 -07:00
Dongbo Wang e64aceccdd Make sure to generate the 'OnIdle' event when there are other subscribers (#899) 2019-04-18 16:33:08 -07:00
Dongbo Wang c197e7e9b2 Fix 'Shift+Backspace/Escape' to work the same as 'Backspace/Escape' on Windows (#898) 2019-04-18 09:54:41 -07:00
Jason Shirk a7af25aa37 Stop dispatching on ConsoleKeyInfo (#831)
There are likely issues introduced by this PR,
but I'm merging for a new Beta so this code gets more testing.

* Introduce PSKeyInfo type alias
* Explicit conversions b/w ConsoleKeyInfo and PSKeyInfo
* Change tests to use actual ConsoleKeyInfo data
* Add fr-FR keyboard layout tests
* Add KeyInfo-ru-RU-windows.json (#839)

All impossible without Shift shortcuts labeled as "Investigate: true"
Alt+Spacebar tracked by windows itself

* Add KeyInfo for Polish (Programmers) layout on Windows and Linux (#870)

On Windows *Alt+Spacebar* is hijacked by Windows
On Linux any *Alt+F1-12* combination was not detected
2019-03-20 16:14:05 -07:00
Jason Shirk 3d246d935f Remove Keys.ShouldInsert (#822)
The method Keys.ShouldInsert was a misguided attempt to avoid inserting
keys where there is no binding but the key really doesn't make sense as
input.

Unfortunately it is just causing more pain and probably wasn't
addressing a serious problem, so I'm removing it.

Fix #798
2018-12-03 11:04:40 -08:00
Dongbo Wang ade48310d0 Remove dependency on the Utility module (#814) 2018-11-26 10:46:24 -08:00
Jason Shirk 52983255fc Disable stdin/stdout check for CI on non-Windows (#804)
Also - only run tests once in AppVeyor.
2018-11-09 10:06:13 -08:00
Jason Shirk bc40ae6f6b Remove uses of CSI # S / ScrollConsoleScreenBuffer (#790)
This fixes some weird issues in WSL and some Linux terminals.

This also works around a Windows 1809 Console bug for the Ctrl+l binding
to clear the screen by using the same escape sequence that bash uses.

Fix #724
2018-11-04 19:12:52 -08:00
Jason Shirk 16ab1c6afe Only restore valid console colors (for non-Windows) 2018-10-23 12:49:58 -07:00
Jason Shirk 170fbde530 Save/restore initial fg/bg colors (#785)
Writing CSI 0 m resets the colors to the terminals initial colors, not
what the settings are before PSReadLine starts.

Fix #774
2018-10-23 12:29:54 -07:00
Steve Lee 1d8dd4a21c Fix unintentional font change in Windows console (#771)
conhost (Windows only) could change the font unexpectedly if the current font is a raster font and the code page changes to UTF8.

PSReadLine was switching to UTF8 output encoding to address some display issues with CJK,

This change skips the UTF8 output encoding change if it would cause conhost to change the font.
2018-10-10 09:16:07 -07:00
Jason Shirk 57bc3a65fd Report environment in execption report 2018-10-02 22:02:02 -07:00
Patrick Meinecke 46960b1fe4 Changes for Editor Hosts (VSCode/Atom) (#626) 2018-06-04 23:16:59 -07:00
Jianyun b83522b43d Fixed cursor position after resize (#694)
Add tracking of buffer height to recalculate initial coordinates.

Fix #682
2018-06-03 20:01:19 -07:00
Dongbo Wang 62cf9f84cc Disable PSReadline on Unix when stdin or stdout is redirected (#648)
Fixes #625.
2018-03-20 11:20:17 -07:00
Jason Shirk c3868e1250 Ignore exceptions Console.OutputEncoding
The output encoding is set for CJK characters, so if that fails, it
would be nice to know, but it comes up often (redirected input,
legacy conhost) so we just ignore the exception.
2017-12-17 22:24:25 -08:00
Jason Shirk be253cdacf Don't restore output encoding when closing
Setting Console.OutputEncoding can hang on Win7 if the console is closing
and there is no point, so don't bother doing that when closing.

Fix #609.
2017-12-16 23:27:11 -08:00
Jason Shirk 09b693014e Enable Ctrl+c on non-Windows
I missed `Console.TreatControlCAsInput` when refactoring the port from
PowerShell/PowerShell - this isn't needed on Windows because it was
handled more directly via SetConsoleMode.

Fix #610
2017-12-16 09:08:29 -08:00
Jason Shirk f1705e9bb2 Switch from MSTest to xUnit, enable tests in AppVeyor (#600) 2017-12-15 11:59:57 -08:00
Jason Shirk 8bc665daed Add support for pre-Win10
Introduced a very minimal terminal emulator, enough to support the
colors used by default (ConsoleColor).

There could be some more error checking or just somehow ignoring unknown
escapes, but we'll see if this is sufficient for now.

Fix #596
2017-12-02 12:02:51 -08:00
Jason Shirk b2c04745e0 Don't add immediate duplicates to history
Also add a public api to access PSReadLine history (helpful in testing
this change.

Fix #562 #533
2017-11-26 17:51:46 -08:00
Jason Shirk 46d232c22a s/PSReadline/PSReadLine/g
I was terribly inconsistent.

This is a breaking change, though unlikely to cause troubles.
The apis are mostly used in PowerShell scripts which is not
case sensitive.
The cmdlet name change is also mostly safe.

At any rate, this is version 2.0 and breaking changes should be OK.
2017-11-25 21:59:55 -08:00
Jason Shirk 193b4da3ac Fix cursor placement after history replacement
A fix for vi mode broke placing the cursor after recalling commands from
history.

There was also a small inconcistency in placing the cursor in vi mode
when in command mode.

Fix #592
2017-11-25 21:30:45 -08:00
Jason Shirk 4226bd4683 Catch and ignore execptions in GetPrompt
The reported bug doesn't repro because the call to GetPrompt in
Initialize is gone, but the issue could still pop up, e.g. during
completion, so I added a try/catch.

Fix #583
2017-11-25 17:29:09 -08:00