70 Commits
Author SHA1 Message Date
Dongbo Wang 0824ad134f Make HistorySearchBackward and HistorySearchForward able to navigate the list view (#3144) 2022-01-11 15:38:49 -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 1280763116 Make the default sensitive history scrubbing function a little smarter (#2921) 2021-10-13 17:43:02 -07:00
Dongbo Wang 118b9e5238 Release mutex when facing AbandonedMutexException (#2867) 2021-09-20 09:25:12 -07: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 fd9980642c Fix incremental history saving when the history queue is full (#1602) 2020-06-15 10:00:44 -07:00
Dongbo Wang ba5294f88a Make edit group more stable in VI mode (#1526) 2020-05-18 13:29:29 -07:00
Dongbo Wang 24636202f8 Relax the sensitive words we filter (#1517) 2020-05-12 13:43:58 -07:00
Dongbo Wang 9e6c6b9481 Add basic support for inline predictive suggestion (#1496) 2020-05-09 15:44:04 -07:00
Dongbo Wang 8b778c6119 Correct the default foreground/background colors (#1435) 2020-03-30 15:43:22 -07: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
Dongbo Wang d648aed6da Fix the exception when searching history with ctrl+r or ctrl+s (#1256) 2019-12-20 23:00:17 -08:00
Dongbo Wang 11d5e5081e Handle 'PSObject' correctly so that script block handlers works for 'AddToHistoryHandler' (#1068) 2019-09-26 10:17:21 -07:00
Dongbo Wang 394bacc1b5 Make the history file mutext name unique across sessions (#1061) 2019-09-23 16:16:35 -07:00
Dongbo Wang 239955c035 Filter sensitive history items and avoid writing them to the history file (#1058) 2019-09-23 13:20:15 -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 c2ff21ef9a Honor HistorySearchCursorMovesToEnd in HistorySearch
Fix #438
2017-11-26 18:07:30 -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 9094f1246b Generate parts of the about topic
To keep the about topic up to date, the function descriptions and key
binding information is now generated after a build.
2017-11-24 22:11:13 -08:00
Jason Shirk 63d2dcf6da Portable custom key bindings
Rewrote the custom key binding code to be more portable.

Some runtime checks are necessary because of impossible to reconcile
differences.

Some Win32 P/Invoke calls are still needed due to lack of information in
the ConsoleKeyInfo.

Some keys are currently not available on Linux due to a CLR bug, others
aren't available ever because terminals don't unique character sequences
for a given key press that might differ in just the Shift or Ctrl state.
2017-10-15 22:03:56 -07:00
Jason Shirk bff16f4beb Correct resources namespace 2017-09-04 23:20:37 -07:00
Jason Shirk de5d7bd701 Merge Foreground/Background options
Fix selection to use escape sequence for invert - it doesn't look that
great when there are too many colors, but it will work with any
customization.

Also fix tests to work after previous commit.
2017-08-14 08:56:22 -07:00
Jason Shirk 138b226ea8 Add basic support for custom colors
Colors can now be customized using RGB (like #RRGGBB) or with escape
sequences.
2017-08-14 08:56:21 -07:00
Jason Shirk 72d1a31002 Use null propagation 2017-07-31 17:33:46 -07:00
Jason Shirk 443b9a5240 use nameof 2017-07-31 17:22:23 -07:00
Jason Shirk 4aba251bdb Remove unused using directives 2017-07-31 16:44:06 -07:00
Jason Shirk a7c0a907e1 Use null coalescing operator 2017-07-31 16:38:43 -07:00
Jason Shirk fc55704f83 Inline out variable parameters 2017-07-31 16:24:57 -07:00
Jason Shirk 7e44fe0d8d Avoid infinite loop when reading history
If there was a single abandoned mutex, and the history file is read
sucessfully after the abandoned mutex, we would enter an inifite loop
reading the history file until we got a couple more abandoned mutexes.

Fixes #524
2017-06-01 09:56:09 -07:00
srdubya 2353cbc85a Honor HistorySearchCursorMovesToEnd in Vi mode (#532)
Fixes #530
2017-05-28 18:46:59 -07:00
Jason Shirk (POWERSHELL) 04c7233b46 Globally suppress 'default args should not be used' 2016-04-27 16:36:50 -07:00
Jason Shirk (POWERSHELL) 0879b08e67 Handle abandoned mutex exception 2016-01-17 09:04:35 -08:00
jason@truewheels.net 22694843e9 Better error for history file access issues
When there is an IO error trying to create the directory for the history file, or some other sort of error trying to read or write the history file, we shouldn't tell the user to report a bug.

Instead, the error will just report the exception message, and if it happens twice, suggest some solutions.

The error will not be reported more than twice, because that would be too annoying.
Fixes #322
2015-12-30 22:42:32 -08:00
srdubya 005c817298 Move cursor to position 0 on history movement. 2015-07-20 07:03:13 -06:00
srdubya ab52d2b642 1st attempt at merge with #251. 2015-06-20 16:47:33 -06:00
Jason Shirk (POWERSHELL) 94a6ba40c9 Fix/suppress various FxCop errors 2015-06-18 18:24:23 -07:00
Jason Shirk (POWERSHELL) c986e0eae5 Rename namespace PSConsoleUtilities to Microsoft.PowerShell 2015-06-18 15:32:20 -07:00
Jason Shirk (POWERSHELL) 6408a4c96c Add copyright header 2015-06-18 15:04:49 -07:00
srdubya 796e90bc60 Corrected a few uncessary file differences, mostly indentation issues. 2015-06-06 13:05:05 -06:00
srdubya 39f37093ec Sync'd with upstream. 2015-03-08 07:58:49 -06:00
jason@truewheels.net 17856e99a1 Remove demo mode
Demo mode doesn't work right now, and I found a better alternative
here:  https://github.com/Code52/carnac

Fixes #192
2015-01-26 19:45:41 -08:00
srdubya 5b832ca5e4 Fixex cursor positioning after history change bug. 2015-01-25 10:33:46 -07:00
jason@truewheels.net 3025a5249d Fix HistorySearch* when line is empty
The commit 49a4c4c1e6 broke
arrow keys working when the line was empty and you wanted
to go back more than one command.
2015-01-21 16:12:06 -08:00
jason@truewheels.net 49a4c4c1e6 History recall should ignore other sesions
When using UpArrow, people prefer not recalling commands
from other currently running sessions.

It's still useful to avoid entering commands that have
might have been entered in another currently running session,
so those commands can still be found when *searching*
history, either interactively, or if the search string
is not empty when using HistorySearch[Backward|Forward].

Also fixed in this change - an obscure bug where
HistoryNoDuplicates did not work well with a DigitArgument
when recalling history.

Fixes #179
2015-01-21 09:13:29 -08:00
srdubya 16f0ad9c5c Sync'd with Upstream. 2014-12-22 18:27:22 -07:00
jason@truewheels.net dff47936ea Bind Alt+F7 to ClearHistory
cmd/PowerShell Windows mode supports clearing history with Alt+F7, so PSReadline will too.
2014-11-25 19:35:22 -08:00
jason@truewheels.net 3bb3e30bef Fix exception after AcceptAndGetNext
The "current" line cleared after accepting via AcceptAndGetNext
and we would crash trying to recall this current line.

I've changed how history search works after AcceptAndGetNext
to work in a more natural way so that arrow keys can be used
to recall commands near the accepted command instead of
searching for other commands with the same prefix.

Fixes #152.
2014-09-26 18:19:23 -07:00
jason@truewheels.net a6894489db Add ValidateAndAcceptLine function
To avoid cluttering the screen and history with command lines
that don't work because of stupid errors like "command not found",
you can bind enter to ValidateAndAcceptLine.
2014-09-11 09:13:06 -07:00