Skip to content
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 #11068: Interactive window should allow to add commands to history without execution #11078

Merged
merged 6 commits into from
May 23, 2016

Conversation

AlexanderSher
Copy link
Contributor

No description provided.

@dnfclas
Copy link

dnfclas commented May 5, 2016

Hi @AlexanderSher, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@@ -307,6 +312,13 @@ public void ClearView()
edit.Apply();
}

if (HistoryBuffer != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: brace on a new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

insertionIndex = IndexOfLastSpan(sourceSpans, ReplSpanKind.Prompt);
break;
default:
throw new ArgumentOutOfRangeException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an odd exception to throw here. InvalidOperationException would be more appropriate.

@tmat
Copy link
Member

tmat commented May 19, 2016

@genlu Please take a look.

}


var historyBuffer = _factory.CreateAndActivateBuffer(_window);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the implementation of the VS implementation of CreateAndActivateBuffer it seems that this is unnecessary for history buffer - it's wiring up undo manager and command filters.

Doing this should be sufficient:

        IContentType contentType;
        if (!window.Properties.TryGetProperty(typeof(IContentType), out contentType))
        {
            contentType = _contentTypeRegistry.GetContentType("text");
        }

        var historyBuffer = _textBufferFactoryService.CreateTextBuffer(contentType);

Also, I think we should set properties:

buffer.Properties.AddProperty(typeof(IInteractiveEvaluator), Evaluator);
buffer.Properties.AddProperty(typeof(InteractiveWindow), _window);

they are set on all language buffers.

- Move state check to the beginning of the method
- Use InvalidOperationException instead of ArgumentOutOfRangeException
@AlexanderSher
Copy link
Contributor Author

Issues fixed

@tmat
Copy link
Member

tmat commented May 20, 2016

One more thing: could you add a comment to the public AddToHistory method that it throws InvalidOperationException when the REPL is in certain states?

👍


break;
default:
throw new InvalidOperationException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw ExceptionUtilities.UnexpectedValue(State); since this is supposedly to be exhaustive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have ExceptionUtilities available here, or do we?

@tmat tmat added this to the 1.3 milestone May 23, 2016
@tmat
Copy link
Member

tmat commented May 23, 2016

@MattGertz Ask mode PR to support RTVS.

- Added test that verifies history navigation
@tmat
Copy link
Member

tmat commented May 23, 2016

👍

@genlu
Copy link
Member

genlu commented May 23, 2016

👍

@tmat tmat merged commit 030cee0 into dotnet:master May 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants