Example #1
0
        private bool MakeFormattedTable(DocumentLine line, bool isEnteredNewLine, int?newColumnIndex)
        {
            GherkinTableBuilder builder = new GherkinTableBuilder(Document, line, isEnteredNewLine, newColumnIndex);
            GherkinTable        table   = builder.Build();

            if (table == null)
            {
                return(false);
            }

            string table_text = table.Format();

            if (!table_text.EndsWith(Environment.NewLine, StringComparison.Ordinal))
            {
                table_text += Environment.NewLine;
            }

            // We need to replace newly entered new line when formatting table by entering new line
            // New line length is 2 because it is "\r\n"
            int new_line_length = isEnteredNewLine ? 2 : 0;

            Document.Replace(builder.Offset, builder.Length + new_line_length, table_text);

            return(true);
        }
Example #2
0
        public static Tuple <DocumentLine, string> FormatTable(TextDocument document, DocumentLine line, int endLine)
        {
            Tuple <DocumentLine, List <string> > table_rows = ExtractTableText(document, line, endLine);
            GherkinTable table      = GherkinTableBuilder.BuildTable(table_rows.Item2);
            string       table_text = table.Format();

            return(new Tuple <DocumentLine, string>(table_rows.Item1, table_text));
        }
Example #3
0
        public string GetTableText()
        {
            int tableColumnCount = GetTableColumnCount();

            if (tableColumnCount == 0)
            {
                return("");
            }

            List <string> rows         = ExtractTableText(tableColumnCount);
            var           gherkinTable = GherkinTableBuilder.BuildTable(rows, false);

            return(gherkinTable.Format());
        }