Browse Source

Pressing the up key in the Python Console no longer closes the completion window if there is command history.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3816 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
dd315fcf54
  1. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ITextEditor.cs
  2. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
  3. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs
  4. 57
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/KeysPressedWhenCompletionWindowOpenTestFixture.cs
  5. 7
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockTextEditor.cs
  6. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

5
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ITextEditor.cs

@ -93,6 +93,11 @@ namespace ICSharpCode.PythonBinding @@ -93,6 +93,11 @@ namespace ICSharpCode.PythonBinding
/// Shows the code completion window.
/// </summary>
void ShowCompletionWindow(ICompletionDataProvider completionDataProvider);
/// <summary>
/// Indicates whether the completion window is currently being displayed.
/// </summary>
bool IsCompletionWindowDisplayed {get;}
/// <summary>
/// Makes the current text content read only. Text can be entered at the end.

4
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs

@ -212,6 +212,10 @@ namespace ICSharpCode.PythonBinding @@ -212,6 +212,10 @@ namespace ICSharpCode.PythonBinding
/// </summary>
bool ProcessDialogKeyPress(Keys keyData)
{
if (textEditor.IsCompletionWindowDisplayed) {
return false;
}
if (IsInReadOnlyRegion) {
switch (keyData) {
case Keys.Left:

4
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs

@ -158,6 +158,10 @@ namespace ICSharpCode.PythonBinding @@ -158,6 +158,10 @@ namespace ICSharpCode.PythonBinding
}
}
public bool IsCompletionWindowDisplayed {
get { return completionWindow != null; }
}
/// <summary>
/// Gets the range of the currently selected text.
/// </summary>

57
src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/KeysPressedWhenCompletionWindowOpenTestFixture.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using Microsoft.Scripting.Hosting.Shell;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Console
{
/// <summary>
/// Pressing the up key closes the completion window when it should not. This fixture tests
/// that the up, down, home and end key do not close this window.
/// </summary>
[TestFixture]
public class KeysPressedWhenCompletionWindowOpenTestFixture
{
PythonConsole pythonConsole;
MockTextEditor textEditor;
string prompt = ">>> ";
[SetUp]
public void Init()
{
textEditor = new MockTextEditor();
pythonConsole = new PythonConsole(textEditor, null);
pythonConsole.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
pythonConsole.Write(prompt, Style.Prompt);
textEditor.RaiseKeyPressEvent('b');
textEditor.RaiseKeyPressEvent('.');
}
[Test]
public void UpKeyDoesNothing()
{
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Up));
}
[Test]
public void DownKeyDoesNothing()
{
Assert.IsFalse(textEditor.RaiseDialogKeyPressEvent(Keys.Down));
}
}
}

7
src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockTextEditor.cs

@ -33,6 +33,7 @@ namespace PythonBinding.Tests.Console @@ -33,6 +33,7 @@ namespace PythonBinding.Tests.Console
bool showCompletionWindowCalled;
bool makeReadOnlyCalled;
ICompletionDataProvider completionProvider;
bool completionWindowDisplayed;
public MockTextEditor()
{
@ -210,9 +211,15 @@ namespace PythonBinding.Tests.Console @@ -210,9 +211,15 @@ namespace PythonBinding.Tests.Console
public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
{
showCompletionWindowCalled = true;
completionWindowDisplayed = true;
this.completionProvider = completionDataProvider;
}
public bool IsCompletionWindowDisplayed {
get { return completionWindowDisplayed; }
set { completionWindowDisplayed = value; }
}
public void MakeCurrentContentReadOnly()
{
makeReadOnlyCalled = true;

1
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -70,6 +70,7 @@ @@ -70,6 +70,7 @@
<Compile Include="AddInFileTestFixture.cs" />
<Compile Include="CompilingOptionsPanelTestFixture.cs" />
<Compile Include="Console\BuiltinCodeCompletionTestFixture.cs" />
<Compile Include="Console\KeysPressedWhenCompletionWindowOpenTestFixture.cs" />
<Compile Include="Console\CommandLineHistoryTestFixture.cs" />
<Compile Include="Console\DerivedPythonConsoleHost.cs" />
<Compile Include="Console\DisposedPythonConsoleTestFixture.cs" />

Loading…
Cancel
Save