public void CreateForVisualSpan_Block() { Create("cat", "dog"); var visualSpan = VisualSpan.NewBlock(_textView.GetBlockSpan(0, 2, 0, 2)); var visualSelection = VisualSelection.CreateForward(visualSpan); Assert.Equal(_textView.GetLine(1).Start.Add(1), visualSelection.GetCaretPoint(SelectionKind.Inclusive)); Assert.Equal(visualSpan, visualSelection.VisualSpan); }
public void AdjustForSelectionKind_Block_SingleColumnExclusive() { Create("cats", "dogs", "trees"); var blockSpan = _textBuffer.GetBlockSpan(1, 1, 0, 2); var visualSpan = VisualSpan.NewBlock(blockSpan); var visualSelection = VisualSelection.CreateForward(visualSpan); Assert.Equal(visualSelection, visualSelection.AdjustForSelectionKind(SelectionKind.Exclusive)); }
public void Simple() { Create("big dog", "big cat", "big tree", "big fish"); var blockSpan = _vimBuffer.GetBlockSpan(1, 2, 0, 2); var visualSpan = VisualSpan.NewBlock(blockSpan); visualSpan.Select(_textView, SearchPath.Forward); Assert.Equal(blockSpan, _vimBuffer.GetSelectionBlockSpan()); Assert.Equal(TextSelectionMode.Box, _textView.Selection.Mode); }
private void EnterBlock(BlockSpan blockSpan) { var visualSpan = VisualSpan.NewBlock(blockSpan); var visualSelection = VisualSelection.CreateForVisualSpan(visualSpan); CommonUtil.SelectAndUpdateCaret(_textView, visualSelection); Assert.IsFalse(_context.IsEmpty); _context.RunAll(); Assert.IsTrue(_context.IsEmpty); _buffer.SwitchMode(ModeKind.VisualBlock, ModeArgument.None); }
public void VisualSpan_Block_AddLineAbove() { var textBuffer = CreateTextBuffer("cats", "dogs", "fish"); var visualSpan = VisualSpan.NewBlock(textBuffer.GetBlockSpan(1, 2, 1, 2)); var trackingVisualSpan = _bufferTrackingService.CreateVisualSpan(visualSpan); textBuffer.Insert(textBuffer.GetLine(1).Start, Environment.NewLine); var newVisualSpan = VisualSpan.NewBlock(textBuffer.GetBlockSpan(1, 2, 2, 2)); Assert.True(trackingVisualSpan.VisualSpan.IsSome()); Assert.Equal(newVisualSpan, trackingVisualSpan.VisualSpan.Value); }
public void AdjustForSelectionKind_Block_MultiColumnExclusive() { Create("cats", "dogs", "trees"); var blockSpan = _textBuffer.GetBlockSpan(1, 2, 0, 2); var visualSpan = VisualSpan.NewBlock(blockSpan); var visualSelection = VisualSelection.CreateForward(visualSpan); var otherVisualSelection = visualSelection.AdjustForSelectionKind(SelectionKind.Exclusive); var otherBlockSpan = otherVisualSelection.AsBlock().Item1; Assert.Equal(blockSpan.Start, otherBlockSpan.Start); Assert.Equal(1, otherBlockSpan.Width); Assert.Equal(2, otherBlockSpan.Height); }
public void CaretInTabAnchorAboveTab() { Create(4, "trucker", "\tcat"); var blockSpan = new BlockSpan(_textBuffer.GetPoint(1), tabStop: 4, spaces: 1, height: 2); var visualSpan = VisualSpan.NewBlock(blockSpan); visualSpan.Select(_textView, SearchPath.Forward); Assert.Equal( new[] { _textBuffer.GetLineSpan(0, 0, 4), _textBuffer.GetLineSpan(1, 0, 1) }, _textView.Selection.SelectedSpans); }
public void SimpleCaretPastTab2() { Create("trucker", "\tcat"); var blockSpan = new BlockSpan(_textBuffer.GetPoint(1), tabStop: 2, spaces: 3, height: 2); var visualSpan = VisualSpan.NewBlock(blockSpan); visualSpan.Select(_textView, SearchPath.Forward); Assert.Equal( new[] { _textBuffer.GetLineSpan(0, 1, 3), _textBuffer.GetLineSpan(1, 1, 2) }, _textView.Selection.SelectedSpans); }
public void SimpleCaretPastTab() { Create("trucker", "\tcat"); var blockSpan = new BlockSpan(_textBuffer.GetPoint(1), tabStop: 2, spaces: 2, height: 2); var visualSpan = VisualSpan.NewBlock(blockSpan); visualSpan.Select(_textView, SearchPath.Forward); // It may seem odd for the second span to start on column 1 since the tab is partially // included in the line. However Visual Studio has this behavior. It won't select a // character at the start / end of a selection unless it's completely included Assert.Equal( new[] { _textBuffer.GetLineSpan(0, 1, 2), _textBuffer.GetLineSpan(1, 1, 1) }, _textView.Selection.SelectedSpans); }
public static VisualSpan GetVisualSpanBlock(this ITextBuffer textBuffer, int column, int length, int startLine = 0, int lineCount = 1) { var blockSpanData = GetBlockSpan(textBuffer, column, length, startLine, lineCount); return(VisualSpan.NewBlock(blockSpanData)); }