public void TwoViews_NoScroll() { // Reported in #2673. Create(Enumerable.Range(0, 26).Select(x => ((char)('a' + x)).ToString()).ToArray()); VimHost.FocusedTextView = _textView; _vimBuffer.ProcessNotation("1G"); Assert.Equal(0, _textView.GetFirstVisibleLineNumber()); var visibleLines = _textView.TextViewLines.Count; var altTextView = TextEditorFactoryService.CreateTextView(_textBuffer); var altVimBuffer = CreateVimBuffer(CreateVimBufferData(altTextView)); try { VimHost.FocusedTextView = altTextView; altVimBuffer.ProcessNotation("13G"); Assert.True(altTextView.GetFirstVisibleLineNumber() > visibleLines); var visualSpan = VimUtil.CreateVisualSpanCharacter(_textBuffer.GetLineSpan(13, 1)); var visualSelection = VisualSelection.CreateForward(visualSpan); _vimBuffer.VimTextBuffer.SwitchMode( ModeKind.VisualCharacter, ModeArgument.NewInitialVisualSelection(visualSelection, FSharpOption <SnapshotPoint> .None)); Assert.Equal(0, _textView.GetFirstVisibleLineNumber()); } finally { altVimBuffer.Close(); } }
public void OnEnter2() { var partialCommand = "'<,'>"; _mode.OnEnter(ModeArgument.NewPartialCommand(partialCommand)); Assert.Equal(partialCommand, _modeRaw.Command); }
public void TwoKeysToEscape() { Create(ModeArgument.NewInsertWithCount(2), "hello"); _vimBuffer.Vim.KeyMap.MapWithNoRemap("jj", "<Esc>", KeyRemapMode.Insert); _vimBuffer.Process("jj"); Assert.Equal(ModeKind.Normal, _vimBuffer.ModeKind); }
public void KeyRemap_TwoKeysToEscape() { Create("hello"); _buffer.Vim.KeyMap.MapWithNoRemap("jj", "<Esc>", KeyRemapMode.Insert); _buffer.SwitchMode(ModeKind.Insert, ModeArgument.NewInsertWithCount(2)); _buffer.Process("jj"); Assert.AreEqual(ModeKind.Normal, _buffer.ModeKind); }
public void InsertOverAsCommand() { Create("fish tree"); _vimBuffer.SwitchMode(ModeKind.Replace, ModeArgument.NewInsertWithCount(2)); _vimBuffer.Process("cat"); _vimBuffer.Process(VimKey.Escape); Assert.Equal("catcatree", _textBuffer.GetLine(0).GetText()); Assert.Equal(5, _textView.GetCaretPoint().Position); }
internal static ModeArgument CreateSubstituteArgument( SnapshotSpan span, SnapshotLineRange?range = null, SubstituteData data = null) { range = range ?? SnapshotLineRangeUtil.CreateForSnapshot(span.Snapshot); data = data ?? new SubstituteData("a", "b", SubstituteFlags.None); return(ModeArgument.NewSubstitute(span, range.Value, data)); }
public void Repeat_Delete() { Create(ModeArgument.NewInsertWithCount(2), "doggie"); _textView.MoveCaretTo(1); _vimBuffer.Process(VimKey.Delete); _vimBuffer.Process(VimKey.Escape); Assert.Equal("dgie", _textView.GetLine(0).GetText()); Assert.Equal(0, _textView.GetCaretPoint().Position); }
public void Repeat_InsertText() { Create("dog"); _buffer.SwitchMode(ModeKind.Replace, ModeArgument.NewInsertWithCount(2)); _buffer.Process("cat"); _buffer.Process(VimKey.Escape); Assert.AreEqual("catcat", _textView.GetLine(0).GetText()); Assert.AreEqual(5, _textView.GetCaretPoint().Position); }
public void Repeat_Insert() { Create(ModeArgument.NewInsertWithCount(2), "the cat"); _vimBuffer.Process("hi"); Assert.Equal(2, _textView.GetCaretPoint().Position); _vimBuffer.Process(VimKey.Escape); Assert.Equal("hihithe cat", _textView.GetLine(0).GetText()); Assert.Equal(3, _textView.GetCaretPoint().Position); }
protected void Create(ModeArgument argument, params string[] lines) { _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vimBuffer = Vim.CreateVimBuffer(_textView); _vimBuffer.SwitchMode(ModeKind.Insert, argument); _register = Vim.RegisterMap.GetRegister('c'); _globalSettings = Vim.GlobalSettings; _localSettings = _vimBuffer.LocalSettings; }
public void InitialVisualSelection_Character() { Create("dogs", "cats"); var visualSpan = VimUtil.CreateVisualSpanCharacter(_textBuffer.GetSpan(1, 2)); var visualSelection = VisualSelection.CreateForVisualSpan(visualSpan); _buffer.SwitchMode(ModeKind.VisualCharacter, ModeArgument.NewInitialVisualSelection(visualSelection)); _context.RunAll(); Assert.AreEqual(visualSelection, VisualSelection.CreateForSelection(_textView, VisualKind.Character)); }
public void InitialVisualSelection_Line() { Create("dogs", "cats", "fish"); var lineRange = _textView.GetLineRange(0, 1); var visualSelection = VisualSelection.NewLine(lineRange, true, 1); _buffer.SwitchMode(ModeKind.VisualLine, ModeArgument.NewInitialVisualSelection(visualSelection)); _context.RunAll(); Assert.AreEqual(visualSelection, VisualSelection.CreateForSelection(_textView, VisualKind.Line)); }
public void InitialVisualSelection_Block() { Create("dogs", "cats", "fish"); var blockSpan = _textView.GetBlockSpan(1, 2, 0, 2); var visualSelection = VisualSelection.NewBlock(blockSpan, BlockCaretLocation.BottomLeft); _buffer.SwitchMode(ModeKind.VisualBlock, ModeArgument.NewInitialVisualSelection(visualSelection)); _context.RunAll(); Assert.AreEqual(visualSelection, VisualSelection.CreateForSelection(_textView, VisualKind.Block)); }
internal static ModeArgument CreateSubstituteArgument( SnapshotSpan span, string search, string replace, SubstituteFlags?flags = null, SnapshotLineRange?range = null) { range = range ?? SnapshotLineRangeUtil.CreateForSnapshot(span.Snapshot); var data = new SubstituteData(search, replace, flags ?? SubstituteFlags.None); return(ModeArgument.NewSubstitute(span, range.Value, data)); }
public void Repeat_WhiteSpaceChange() { Create(ModeArgument.NewInsertWithCount(2), "blue\t\t dog"); _vimBuffer.LocalSettings.TabStop = 4; _vimBuffer.LocalSettings.ExpandTab = false; _textView.MoveCaretTo(10); _textBuffer.Replace(new Span(6, 4), "\t\t"); _textView.MoveCaretTo(8); Assert.Equal("blue\t\t\t\tdog", _textBuffer.GetLine(0).GetText()); _vimBuffer.Process(VimKey.Escape); Assert.Equal("blue\t\t\t\t\tdog", _textBuffer.GetLine(0).GetText()); }
private void Create(ModeArgument argument, params string[] lines) { var tuple = EditorUtil.CreateTextViewAndEditorOperations(lines); _textView = tuple.Item1; _textBuffer = _textView.TextBuffer; var service = EditorUtil.FactoryService; _vimBuffer = service.Vim.CreateVimBuffer(_textView); _vimBuffer.SwitchMode(ModeKind.Insert, argument); _register = Vim.RegisterMap.GetRegister('c'); _globalSettings = Vim.GlobalSettings; _localSettings = _vimBuffer.LocalSettings; }
public static bool IsSwitchModeWithArgument(this ProcessResult result, ModeKind kind, ModeArgument argument) { return(result.IsHandled && result.AsHandled().Item.IsSwitchModeWithArgument(kind, argument)); }
public static bool IsSwitchModeWithArgument(this ModeSwitch mode, ModeKind kind, ModeArgument argument) { if (!mode.IsSwitchModeWithArgument) { return(false); } var value = (ModeSwitch.SwitchModeWithArgument)mode; return(value.Item1 == kind && value.Item2.Equals(argument)); }
public void OnEnter(ModeArgument arg) { throw new NotImplementedException(); }
public void Bind_SwitchMode_Command() { Create(""); _commandUtil.SetupCommandNormal(NormalCommand.NewSwitchMode(ModeKind.Command, ModeArgument.NewPartialCommand("'<,'>"))); _mode.Process(":"); _commandUtil.Verify(); }
public IMode SwitchMode(ModeKind value, ModeArgument arg) { ModeKindImpl = value; return(GetMode(value)); }
public void RaiseSwitchedMode(IMode mode, ModeArgument arg = null) { RaiseSwitchedMode(new SwitchModeEventArgs(mode, mode, arg ?? ModeArgument.None)); }
public void NormalModeOneTimeCommand1() { var res = _mode.Process(KeyNotationUtil.StringToKeyInput("<C-o>")); Assert.IsTrue(res.IsSwitchModeWithArgument(ModeKind.Normal, ModeArgument.NewOneTimeCommand(ModeKind.Insert))); }
protected override void Create(ModeArgument argument, params string[] lines) { base.Create(argument, lines); _globalSettings.AtomicInsert = true; }
public IMode SwitchMode(ModeKind value, ModeArgument arg) { ModeKindImpl = value; return GetMode(value); }