@@ -3,6 +3,7 @@ import { AlignmentFactory } from "./alignmentFactory";
33import { Alignment } from "../models/alignment" ;
44import { Transformer } from "./transformers/transformer" ;
55import { SelectionInterpreter } from "./selectionInterpreter" ;
6+ import { TableIndentationDetector } from "./tableIndentationDetector" ;
67import { Cell } from "../models/cell" ;
78import { Line } from "../models/doc/line" ;
89import { Row } from "../models/row" ;
@@ -14,11 +15,12 @@ export class TableFactory {
1415 constructor (
1516 private _alignmentFactory : AlignmentFactory ,
1617 private _selectionInterpreter : SelectionInterpreter ,
17- private _transformer : Transformer )
18+ private _transformer : Transformer ,
19+ private _tableIndentationDetector : TableIndentationDetector )
1820 { }
1921
2022 public getModel ( document : Document , range : Range ) : Table {
21- const lines = document . getLines ( range ) ;
23+ const lines : Line [ ] = document . getLines ( range ) ;
2224 if ( lines == null || lines . length == 0 )
2325 throw new Error ( "Can't create table model from no lines." ) ;
2426
@@ -38,6 +40,8 @@ export class TableFactory {
3840 ? this . _alignmentFactory . createAlignments ( separator )
3941 : [ ] ;
4042
41- return this . _transformer . process ( new Table ( rowsWithoutSeparator , separatorLine . EOL , alignments ) ) ;
43+ const leftPad : string = this . _tableIndentationDetector . getLeftPad ( lines . map ( l => l . value ) ) ;
44+
45+ return this . _transformer . process ( new Table ( rowsWithoutSeparator , separatorLine . EOL , alignments , leftPad ) ) ;
4246 }
4347}
0 commit comments