Example #1
0
        public IEnumerable <SuggestedActionSet> GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
        {
            var span      = new SnapshotSpan(_view.Selection.Start.Position, _view.Selection.End.Position);
            var startLine = span.Start.GetContainingLine().Extent;
            var endLine   = span.End.GetContainingLine().Extent;

            var selectionStart = _view.Selection.Start.Position.Position;
            var selectionEnd   = _view.Selection.End.Position.Position;
            var SelectedSpan   = new SnapshotSpan(span.Snapshot, selectionStart, selectionEnd - selectionStart);

            var list = new List <SuggestedActionSet>();

            if (!_view.Selection.IsEmpty && startLine == endLine)
            {
                var convertToLink  = new ConvertToLinkAction(SelectedSpan, _view);
                var convertToImage = new ConvertToImageAction(SelectedSpan, _file);
                list.AddRange(CreateActionSet(convertToLink, convertToImage));
            }

            var convertToQuote     = new ConvertToQuoteAction(SelectedSpan, _view);
            var convertToCodeBlock = new ConvertToCodeBlockAction(SelectedSpan, _view);

            list.AddRange(CreateActionSet(convertToQuote, convertToCodeBlock));

            return(list);
        }
Example #2
0
        public IEnumerable <SuggestedActionSet> GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
        {
            var span      = new SnapshotSpan(_view.Selection.Start.Position, _view.Selection.End.Position);
            var startLine = span.Start.GetContainingLine().Extent;
            var endLine   = span.End.GetContainingLine().Extent;

            var selectionStart = _view.Selection.Start.Position.Position;
            var selectionEnd   = _view.Selection.End.Position.Position;
            var SelectedSpan   = new SnapshotSpan(span.Snapshot, selectionStart, selectionEnd - selectionStart);

            var list = new List <SuggestedActionSet>();

            //AddMissingFile
            var addMissingFileAction = AddMissingFileAction.Create(GetErrorTags(_view, SelectedSpan), _file, _view);

            if (addMissingFileAction != null)
            {
                list.AddRange(CreateActionSet(addMissingFileAction));
            }

            if (!_view.Selection.IsEmpty && startLine == endLine)
            {
                var convertToLink  = new ConvertToLinkAction(SelectedSpan, _view);
                var convertToImage = new ConvertToImageAction(SelectedSpan, _file);
                list.AddRange(CreateActionSet(convertToLink, convertToImage));
            }

            // Blocks
            var convertToQuote     = new ConvertToQuoteAction(SelectedSpan, _view);
            var convertToCodeBlock = new ConvertToCodeBlockAction(SelectedSpan, _view);

            list.AddRange(CreateActionSet(convertToQuote, convertToCodeBlock));

            // Lists
            var convertToUnorderedList = new ConvertToUnorderedList(SelectedSpan, _view);
            var convertToOrderedList   = new ConvertToOrderedList(SelectedSpan, _view);
            var convertToTaskList      = new ConvertToTaskList(SelectedSpan, _view);

            list.AddRange(CreateActionSet(convertToUnorderedList, convertToOrderedList, convertToTaskList));

            return(list);
        }