Example #1
0
        public async Task ToggleHistoryEntriesRangeSelectionDown_AfterRangeSelection(int rangeStart, int rangeEnd, string selectedText)
        {
            var input = @"f <- function() {
    print(42)
}
g <- function() {
    print(7*9)
}
h <- function() {
    print(42)
}";

            _history.AddToHistory(input);
            _history.SelectHistoryEntry(rangeStart);
            _history.SelectHistoryEntriesRangeTo(rangeEnd);

            await DoEvents();

            _history.ToggleHistoryEntriesRangeSelectionDown();

            await DoEvents();

            _history.GetSelectedHistoryEntrySpans().Should().ContainSingle()
            .Which.GetText().Should().Be(selectedText);
        }
        private bool HandleSingleClick(InputEventArgs e, ModifierKeys modifiers)
        {
            // Don't do anything if there is no history
            if (_history.VisualComponent.TextView.TextBuffer.CurrentSnapshot.Length == 0)
            {
                return(true);
            }

            var point      = GetAdjustedPosition(e, _history.VisualComponent.TextView);
            var lineNumber = GetLineNumberUnderPoint(point);

            if (lineNumber == -1)
            {
                return(false);
            }

            switch (modifiers)
            {
            case ModifierKeys.None:
                _history.ClearHistoryEntrySelection();
                _history.SelectHistoryEntry(lineNumber);
                return(false);

            case ModifierKeys.Control:
                _history.VisualComponent.TextView.Selection.Clear();
                _history.ToggleHistoryEntrySelection(lineNumber);
                return(true);

            case ModifierKeys.Shift:
                if (_history.HasSelectedEntries)
                {
                    _history.SelectHistoryEntriesRangeTo(lineNumber);
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }