-
Notifications
You must be signed in to change notification settings - Fork 76
Improved User Experience for History #39
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
Conversation
|
Looks like I'm running into this issue. Appveyor looks to be running a slightly older version than I am. (v2.1.101). Works find on my Mac running 2.1.4. I also verified that it works on Travis. |
|
@rubberduck203 can you please look into the test failures? |
|
It looks to me like Appveyor’s getting a stale commit somehow. I removed the code that was causing the failure, but the Debug build is failing. I’ll take another look later today. |
|
There we go. Super green. |
|
Looks okay to me now as long as its tested. GNU Readline has the following:
|
|
All good except C-d, but I checked out the tip of your master branch and I'm seeing the same problem. |
|
That is a bit more difficult to do without termios esc-seqs in Windows. Can you try something like this:
|
|
Are you asking me to fix a bug that also exists on master? I’m not following what you want me to do. |
|
Since you are in there testing stuff out, could you let us know what needs fixed so we can patch it? You had mentioned "All good except C-d," If that hotkey is broken, it is worth investigating. |
|
Sure. I should have a few minutes sometimes soon. I’ll open an issue about it later so we can track that separately. |
The optimized clear line wasn't taking the prompt into consideration. This caused us to lose the prompt when scrolling through history. Comparing Console.CursorLeft to text length lets us know how much of the line to clear.
|
I just discovered a bug in this implementation. |
|
You may want to check the width of the terminal and compare that against your startColumn. I do know, that xterm/termios will wrap and typical is x_max=80 for console. This could be a possible cause, hence why I prefered the original method via the loop iterator to stride over the width as the preferred method of impl. Granted!! It does appear suspect and needs attention. |
|
Yeah. You can get the correct information via the following formulas. Or something close to that anyway. The problem is that the total text length must include the length of the prompt text, which is currently unavailable to the |
|
You can get the prompt environment variable from: #if POSIX
system( "\`env\` | grep PROMPT" ); // [e.g. if it exists] and then do a <string>.Length comparison to evaluate.
#endif For non-POSIX based OS's, you may want to look at the equivalent for that. However, since we are deploying with .NET Core/STD... this should be sufficient. E.g. 'return $CWD.Length' internal static int PromptLength() {
var process = new Process
{
StartInfo = new ProcessStartInfo("cmd")
{
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
CreateNoWindow = true,
Arguments = "/k",
}
};
process.Start();
try {
process.StandardInput.WriteLine();
process.StandardInput.Flush();
var str = process.StandardOutput.ReadLine();
return str?.Length ?? -1;
} finally {
process.Kill();
}
} |
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.
Revert changes to KeyHandlerTests.cs.
Reason:
Redundancy... See jump-table macros for ConsoleKeyInfo.
|
No. It’s not a redundant test. During development I had all green tests, but still managed to cause an invalid access to an array. This is the test I wrote to cover the case. |
|
Have you compared it against 'master'? MoveCursorThenPreviousHistory() is already defined in the unit tests. It uses the method group as its parameter for Handle(...) which reuses the definitions already defined essentially being the equivalent to your explicit implementation. E.g. LeftArrow, UpArrow [Fact]
public void MoveCursorThenPreviousHistory()
{
_keyHandler.Handle(LeftArrow);
_keyHandler.Handle(UpArrow);
Assert.Equal("clear", _keyHandler.Text);
} |
|
I am not seeing anything wrong with what Toni merged from you 2 days ago in PR#40. Perhaps, you refined it since. This PR#39 shows different than what I had merged shortly after he did and the file I mentioned is stale. I believe we are on the same page. The code above should be the final draft. What I am not understanding is why the PR remains open if it has already been pulled from you and merged into master. My only guess is he CAN'T because the last file I am mentioning conflicts. Toni likes to cherry pick stuff in his branch and really confuses the tracking on these PR's. He did it with my new VS2017 X-Platform build configurations 6 months ago and I was the one that wrote all that code hence my PR was never merged similarly. Go figure!!! I will send him an email to try and get this sorted out. |
|
I’m confused. Which branch? I don’t see this on master. It’s in my master that I’ve been cherry-picking from for these PRs. I’ve had to cherry pick because I’m publishing an alternative nuget package based on my tree so I can use these changes in another project. |
|
'Master' branch. I don't have access to merge into 'master' but I pulled yours into mine from your PR-#43. I am almost positive Tony can not merge this PR-#39 due to conflicts (e.g. reverting back to stale code). Remove the changes for the last 2 files or he will be cherry picking the code for the 1st file into his build (thus losing the tracking and credit for your efforts), along with closing this PR. This is what I am going to have to be doing as well since it is just 1 method a dozen lines long. It would appear that your unit tests need merged from PR-#43? I cleaned up your branch and merged them into mine. I am positive Toni will reflect changing the versioning on things once he publishes the .nupkg. Typically, from my experience, you do not mess with the versioning unless you have access to the master branch. |
This PR changes the way clearing the current line works.
Instead of backspacing, it clears the line in one shot.
This speeds up the interface and works more like a typical terminal experience.