コード例 #1
0
ファイル: VisualModeTest.cs プロジェクト: bentayloruk/VsVim
        public void Yank1()
        {
            Create("foo", "bar");
            var span = _textBuffer.GetLineRange(0).Extent;

            _selection.Select(span);
            Assert.IsTrue(_mode.Process('y').IsSwitchPreviousMode());
            Assert.AreEqual("foo", _map.GetRegister(RegisterName.Unnamed).StringValue);
        }
コード例 #2
0
ファイル: CommandRunnerTest.cs プロジェクト: sh54/VsVim
        public void Run_Register2()
        {
            Create(String.Empty);
            var didRun = false;

            _runner.Add(VimUtil.CreateNormalBinding("a", data =>
            {
                Assert.AreSame(_registerMap.GetRegister('c'), data.GetRegister(_registerMap));
                didRun = true;
                return(CommandResult.NewCompleted(ModeSwitch.NoSwitch));
            }));
            Run("\"ca");
            Assert.IsTrue(didRun);
        }
コード例 #3
0
 public void PutOver_CharacterWise_NamedRegisters()
 {
     Create("dog", "cat");
     EnterMode(ModeKind.VisualCharacter, _textView.GetLineSpan(0, 0, 3));
     _registerMap.GetRegister('c').UpdateValue("pig");
     _buffer.Process("\"cp");
     Assert.AreEqual("pig", _textView.GetLine(0).GetText());
     Assert.AreEqual("dog", UnnamedRegister.StringValue);
 }
コード例 #4
0
        public static Register GetRegister(this IRegisterMap map, char c)
        {
            var name = RegisterNameUtil.CharToRegister(c).Value;

            return(map.GetRegister(name));
        }
コード例 #5
0
 public static Register GetRegister(this CommandData commandData, IRegisterMap registerMap)
 {
     return(registerMap.GetRegister(commandData.GetRegisterNameOrDefault()));
 }
コード例 #6
0
ファイル: NormalModeTest.cs プロジェクト: DanBlanchard/VsVim
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _unnamedRegister = _map.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _editorOperations = _factory.Create<IEditorOperations>(MockBehavior.Loose);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _jumpList = _factory.Create<IJumpList>(MockBehavior.Strict);
            _statusUtil = _factory.Create<IStatusUtil>(MockBehavior.Strict);
            _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
            _host = _factory.Create<IVimHost>(MockBehavior.Loose);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _vimData = new VimData();

            _globalSettings = new Vim.GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
            motionUtil = motionUtil ?? VimUtil.CreateTextViewMotionUtil(
                _textView,
                new MarkMap(new TrackingLineColumnService()),
                _localSettings);
            _buffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                "test",
                MockObjectFactory.CreateVim(_map, host: _host.Object, vimData: _vimData).Object,
                _jumpList.Object,
                incrementalSearch: _incrementalSearch.Object,
                motionUtil: motionUtil,
                settings: _localSettings);
            _operations = _factory.Create<ICommonOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_textView);

            var capture = new MotionCapture(
                _host.Object,
                _textView,
                _incrementalSearch.Object,
                new LocalSettings(new GlobalSettings(), EditorUtil.GetEditorOptions(_textView), _textView));
            var runner = new CommandRunner(_textView, _map, capture, _commandUtil.Object, _statusUtil.Object, VisualKind.Character);
            _modeRaw = new NormalMode(
                _buffer.Object,
                _operations.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
コード例 #7
0
ファイル: RegisterMapTest.cs プロジェクト: oraclechang/VsVim
 void AssertRegister(RegisterName name, string value, OperationKind kind)
 {
     AssertRegister(_map.GetRegister(name), value, kind);
 }
コード例 #8
0
ファイル: NormalModeTest.cs プロジェクト: otf/VsVim
        public void CreateCore(ITextViewMotionUtil motionUtil, params string[] lines)
        {
            _view = EditorUtil.CreateView(lines);
            _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
            _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _unnamedRegister = _map.GetRegister(RegisterName.Unnamed);
            _editorOperations = new Mock<IEditorOperations>();
            _incrementalSearch = new Mock<IIncrementalSearch>(MockBehavior.Strict);
            _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
            _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
            _changeTracker = new Mock<IChangeTracker>(MockBehavior.Strict);
            _foldManager = new Mock<IFoldManager>(MockBehavior.Strict);
            _visualSpanCalculator = new Mock<IVisualSpanCalculator>(MockBehavior.Strict);
            _host = new Mock<IVimHost>(MockBehavior.Loose);
            _displayWindowBroker = new Mock<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _bufferData = MockRepository.CreateVimBuffer(
                _view,
                "test",
                MockRepository.CreateVim(_map, changeTracker: _changeTracker.Object, host: _host.Object).Object,
                _jumpList.Object);
            _operations = new Mock<IOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_view);
            _operations.SetupGet(x => x.FoldManager).Returns(_foldManager.Object);

            motionUtil = motionUtil ?? new TextViewMotionUtil(_view, new Vim.LocalSettings(
                    new Vim.GlobalSettings(),
                    _view));
            var capture = new MotionCapture(_host.Object, _view, motionUtil, new MotionCaptureGlobalData());
            var runner = new CommandRunner(_view, _map, (IMotionCapture)capture, _statusUtil.Object);
            _modeRaw = new Vim.Modes.Normal.NormalMode(
                _bufferData.Object,
                _operations.Object,
                _incrementalSearch.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                (ICommandRunner)runner,
                (IMotionCapture)capture,
                _visualSpanCalculator.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
コード例 #9
0
 public void PlusRegister1()
 {
     _clipboard.SetupGet(x => x.Text).Returns("foo").Verifiable();
     Assert.AreEqual("foo", _map.GetRegister('+').StringValue);
     _factory.Verify();
 }