protected override string GetFormatted(bool isSignatureFile, string source, Fantomas.FormatConfig.FormatConfig config)
        {
            Range.pos   startPos = TextUtils.GetFSharpPos(TextView.Selection.Start);
            Range.pos   endPos   = TextUtils.GetFSharpPos(TextView.Selection.End);
            Range.range range    = Range.mkRange("fsfile", startPos, endPos);

            return(Fantomas.CodeFormatter.formatSelectionFromString(isSignatureFile, range, source, config));
        }
        protected override string GetFormatted(bool isSignatureFile, string source, Fantomas.FormatConfig.FormatConfig config)
        {
            // This still seems to give "The indent level cannot be negative"
            // in a lot of cases that feel like they should work, e.g. 'let' forms

            Range.pos   startPos = TextUtils.GetFSharpPos(TextView.Selection.Start);
            Range.pos   endPos   = TextUtils.GetFSharpPos(TextView.Selection.End);
            Range.range range    = Range.mkRange("fsfile", startPos, endPos);

            return(Fantomas.CodeFormatter.formatSelectionFromString(isSignatureFile, range, source, config));
        }
        protected override string GetFormatted(bool isSignatureFile, string source, Fantomas.FormatConfig.FormatConfig config)
        {
            if (isFormattingCursor)
            {
                var       caretPos = new VirtualSnapshotPoint(TextView.TextBuffer.CurrentSnapshot, TextView.Caret.Position.BufferPosition);
                Range.pos pos      = TextUtils.GetFSharpPos(caretPos);
                return(Fantomas.CodeFormatter.formatAroundCursor(isSignatureFile, pos, source, config));
            }

            Range.pos   startPos = TextUtils.GetFSharpPos(TextView.Selection.Start);
            Range.pos   endPos   = TextUtils.GetFSharpPos(TextView.Selection.End);
            Range.range range    = Range.mkRange("fsfile", startPos, endPos);

            return(Fantomas.CodeFormatter.formatSelectionFromString(isSignatureFile, range, source, config));
        }
 public static int GetOffset([NotNull] this IDocument document, Range.pos pos)
 {
     return(GetDocumentOffset(document, (Line)(pos.Line - 1), (Column)pos.Column));
 }