Permalink
Browse files

Merge remote-tracking branch 'origin/release'

Conflicts:
	VimCoreTest/MacroIntegrationTest.cs
	VimCoreTest/SelectModeIntegrationTest.cs
  • Loading branch information...
2 parents 7b7053d + 10413c5 commit 2b370a69be250a3021b61a855f5d387f5a976453 @jaredpar committed Jun 6, 2012
View
@@ -23,12 +23,7 @@
TestResult.xml
# NUnit files
-VsVim.VisualState.xml
-EditorUtils.VisualState.xml
-VsVim.sln.VisualState.xml
-VimCoreTest.csproj.VisualState.xml
-VimWpfTest.csproj.VisualState.xml
-VsVimSharedTest.csproj.VisualState.xml
+*.VisualState.xml
# Resharper
_ReSharper.*
View
@@ -1994,7 +1994,16 @@ type internal CommandUtil
true
| keyInput :: tail ->
- match _vim.FocusedBuffer with
+ // Prefer the focussed IVimBuffer over the current. It's possible for the
+ // macro playback switch the active buffer via gt, gT, etc ... and playback
+ // should continue on the newly focussed IVimBuffer. Should the host API
+ // fail to return an active IVimBuffer continue using the original one
+ let buffer =
+ match _vim.FocusedBuffer with
+ | Some buffer -> Some buffer
+ | None -> _vim.GetVimBuffer _textView
+
+ match buffer with
| None ->
// Nothing to do if we don't have an ITextBuffer with focus
false
@@ -49,6 +49,8 @@ type internal SelectMode
let caretPoint = TextViewUtil.GetCaretPoint _textView
let text = _commonOperations.GetNewLineText caretPoint
x.ProcessInput text
+ elif keyInput.Key = VimKey.Delete || keyInput.Key = VimKey.Back then
+ x.ProcessInput ""
elif Option.isSome keyInput.RawChar then
x.ProcessInput (StringUtil.ofChar keyInput.Char)
else
@@ -29,7 +29,7 @@ private void Create(params string[] lines)
_vimBuffer = Vim.CreateVimBuffer(_textView);
_vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
_globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
- ((MockVimHost)_vimBuffer.Vim.VimHost).FocusedTextView = _textView;
+ VimHost.FocusedTextView = _textView;
}
/// <summary>
@@ -114,6 +114,20 @@ public void RunMacro_NumberedList()
}
}
+ /// <summary>
+ /// If there is no focussed IVimBuffer then the macro playback should use the original IVimBuffer
+ /// </summary>
+ [Test]
+ public void RunMacro_NoFocusedView()
+ {
+ Create("world");
+ VimHost.FocusedTextView = null;
+ TestRegister.UpdateValue("ihello ");
+ _vimBuffer.Process("@c");
+ Assert.AreEqual(ModeKind.Insert, _vimBuffer.ModeKind);
+ Assert.AreEqual("hello world", _textView.GetLine(0).GetText());
+ }
+
/// <summary>
/// When the word completion command is run and there are no completions this shouldn't
/// register as an error and macro processing should continue
@@ -96,6 +96,38 @@ public void SimpleEnter()
Assert.Equal(new[] { "dog ", "time" }, _textBuffer.GetLines());
Assert.Equal(_textBuffer.GetLine(1).Start, _textView.GetCaretPoint());
}
+
+ /// <summary>
+ /// The delete key should delete the selection and not insert any text into the
+ /// line
+ ///
+ /// issue #911
+ /// </summary>
+ [Test]
+ public void DeleteKey()
+ {
+ Create("dog cat bear");
+ EnterSelect(0, 4);
+ _vimBuffer.Process(VimKey.Delete);
+ Assert.AreEqual(ModeKind.Insert, _vimBuffer.ModeKind);
+ Assert.AreEqual("cat bear", _textBuffer.GetLine(0).GetText());
+ Assert.AreEqual(0, _textView.GetCaretPoint().Position);
+ }
+
+ /// <summary>
+ /// The backspace key should delete the selection and not insert any text into the
+ /// line
+ /// </summary>
+ [Test]
+ public void BackspaceKey()
+ {
+ Create("dog cat bear");
+ EnterSelect(0, 4);
+ _vimBuffer.Process(VimKey.Back);
+ Assert.AreEqual(ModeKind.Insert, _vimBuffer.ModeKind);
+ Assert.AreEqual("cat bear", _textBuffer.GetLine(0).GetText());
+ Assert.AreEqual(0, _textView.GetCaretPoint().Position);
+ }
}
public sealed class Misc : SelectModeIntegrationTest
@@ -4,17 +4,17 @@
<SelectedNode>[0-1000]C:\Users\jaredpar\Documents\VsVim\VsVim10.sln</SelectedNode>
<ExcludeCategories>false</ExcludeCategories>
<Nodes>
- <Node UniqueName="[0-1000]C:\Users\jaredpar\Documents\VsVim\VsVim10.sln" Expanded="true" Checked="true" />
+ <Node UniqueName="[0-1000]C:\Users\jaredpar\Documents\VsVim\VsVim10.sln" Expanded="true" />
<Node UniqueName="[0-3543]C:\Users\jaredpar\Documents\VsVim\VimCoreTest\bin\Debug\Vim.Core.UnitTest.dll" Expanded="true" />
<Node UniqueName="[0-3544]Vim" Expanded="true" />
<Node UniqueName="[0-3545]Vim.UnitTest" Expanded="true" />
- <Node UniqueName="[0-3754]C:\Users\jaredpar\Documents\VsVim\VsVimSharedTest\bin\Debug\VsVim.Shared.UnitTest.dll" Expanded="true" />
- <Node UniqueName="[0-3755]VsVim" Expanded="true" />
- <Node UniqueName="[0-3756]VsVim.UnitTest" Expanded="true" />
- <Node UniqueName="[0-3862]C:\Users\jaredpar\Documents\VsVim\VimWpfTest\bin\Debug\Vim.UI.Wpf.UnitTest.dll" Expanded="true" />
- <Node UniqueName="[0-3863]Vim" Expanded="true" />
- <Node UniqueName="[0-3864]Vim.UI" Expanded="true" />
- <Node UniqueName="[0-3865]Vim.UI.Wpf" Expanded="true" />
- <Node UniqueName="[0-3866]Vim.UI.Wpf.UnitTest" Expanded="true" />
+ <Node UniqueName="[0-3756]C:\Users\jaredpar\Documents\VsVim\VsVimSharedTest\bin\Debug\VsVim.Shared.UnitTest.dll" Expanded="true" />
+ <Node UniqueName="[0-3757]VsVim" Expanded="true" />
+ <Node UniqueName="[0-3758]VsVim.UnitTest" Expanded="true" />
+ <Node UniqueName="[0-3864]C:\Users\jaredpar\Documents\VsVim\VimWpfTest\bin\Debug\Vim.UI.Wpf.UnitTest.dll" Expanded="true" />
+ <Node UniqueName="[0-3865]Vim" Expanded="true" />
+ <Node UniqueName="[0-3866]Vim.UI" Expanded="true" />
+ <Node UniqueName="[0-3867]Vim.UI.Wpf" Expanded="true" />
+ <Node UniqueName="[0-3868]Vim.UI.Wpf.UnitTest" Expanded="true" />
</Nodes>
</VisualState>
@@ -29,7 +29,7 @@ internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordina
/// </summary>
protected override bool TryProcess(KeyInput keyInput)
{
- if (TryProcessCore(keyInput))
+ if (IsDiscardedKeyInput(keyInput))
{
return true;
}
@@ -44,7 +44,7 @@ protected override bool TryProcess(KeyInput keyInput)
// be routed through Visual Studio and IOleCommandTarget in order to get intellisense
// properly hooked up. Not handling it in this KeyProcessor will eventually cause
// it to be routed through IOleCommandTarget if it's input
- if (VimBuffer.ModeKind.IsAnyInsert() && VimBuffer.InsertMode.IsDirectInsert(keyInput))
+ if (VimBuffer.ModeKind.IsAnyInsert() && !VimBuffer.CanProcessAsCommand(keyInput))
{
return false;
}
@@ -53,19 +53,18 @@ protected override bool TryProcess(KeyInput keyInput)
}
/// <summary>
- /// Implement the common logic for TryProcess as it relates to Visual Studio specific
- /// input
+ /// Is this KeyInput value to be discarded based on previous KeyInput values
/// </summary>
- private bool TryProcessCore(KeyInput keyInput)
+ private bool IsDiscardedKeyInput(KeyInput keyInput)
{
// Check to see if we should be discarding this KeyInput value. If the KeyInput matches
// then we mark the KeyInput as handled since it's the value we want to discard. In either
// case though we clear out the discarded KeyInput value. This value is only meant to
// last for a single key stroke.
- var handled = _bufferCoordinator.DiscardedKeyInput.IsSome(keyInput);
+ var isDiscarded = _bufferCoordinator.DiscardedKeyInput.IsSome(keyInput);
_bufferCoordinator.DiscardedKeyInput = FSharpOption<KeyInput>.None;
- return handled;
+ return isDiscarded;
}
/// <summary>
@@ -92,5 +92,33 @@ public void KeyDown_DontHandleIfIncrementalSearchActive()
VerifyNotHandle(key);
}
}
+
+ /// <summary>
+ /// When presented with a KeyInput the TryProcess command should consider if the mapped key
+ /// is a direct insert not the provided key.
+ /// </summary>
+ [Test]
+ public void KeyDown_InsertCheckShouldConsiderMapped()
+ {
+ var keyInput = KeyInputUtil.CharWithControlToKeyInput('e');
+ _buffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Insert);
+ _buffer.Setup(x => x.CanProcessAsCommand(keyInput)).Returns(true).Verifiable();
+ VerifyHandle(Key.E, ModifierKeys.Control);
+ _factory.Verify();
+ }
+
+ /// <summary>
+ /// We only do the CanProcessAsCommand check in insert mode. The justification is that direct
+ /// insert commands should go through IOleCommandTarget in order to trigger intellisense and
+ /// the like. If we're not in insert mode we don't consider intellisense in the key
+ /// processor
+ /// </summary>
+ [Test]
+ public void KeyDown_NonInsertShouldntCheckForCommand()
+ {
+ _buffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal).Verifiable();
+ VerifyHandle(Key.E, ModifierKeys.Control);
+ _factory.Verify();
+ }
}
}

0 comments on commit 2b370a6

Please sign in to comment.