@@ -1957,5 +1957,72 @@ describe('Formulas', () => {
1957
1957
] ) ;
1958
1958
}
1959
1959
} ) ;
1960
+
1961
+ it ( 'should apply multiple formula lines sequentially' , ( ) => {
1962
+ {
1963
+ const textEditor = new TextEditor ( [
1964
+ 'foo' ,
1965
+ '| A | B |' ,
1966
+ '| --- | --- |' ,
1967
+ '| 1 | 2 |' ,
1968
+ '| 3 | 4 |' ,
1969
+ '| 5 | 6 |' ,
1970
+ '| | |' ,
1971
+ '<!-- TBLFM: @>$>=@3 -->' ,
1972
+ '<!-- TBLFM: @>$1=@4 -->' ,
1973
+ ] ) ;
1974
+ textEditor . setCursorPosition ( new Point ( 1 , 0 ) ) ;
1975
+ const tableEditor = new TableEditor ( textEditor ) ;
1976
+ const err = tableEditor . evaluateFormulas ( defaultOptions ) ;
1977
+ const pos = textEditor . getCursorPosition ( ) ;
1978
+ expect ( err ) . to . be . undefined ;
1979
+ expect ( pos . row ) . to . equal ( 1 ) ;
1980
+ expect ( pos . column ) . to . equal ( 0 ) ;
1981
+ expect ( textEditor . getSelectionRange ( ) ) . to . be . undefined ;
1982
+ expect ( textEditor . getLines ( ) ) . to . deep . equal ( [
1983
+ 'foo' ,
1984
+ '| A | B |' ,
1985
+ '| --- | --- |' ,
1986
+ '| 1 | 2 |' ,
1987
+ '| 3 | 4 |' ,
1988
+ '| 5 | 6 |' ,
1989
+ '| 5 | 4 |' ,
1990
+ '<!-- TBLFM: @>$>=@3 -->' ,
1991
+ '<!-- TBLFM: @>$1=@4 -->' ,
1992
+ ] ) ;
1993
+ }
1994
+ {
1995
+ const textEditor = new TextEditor ( [
1996
+ 'foo' ,
1997
+ '| A | B |' ,
1998
+ '| --- | --- |' ,
1999
+ '| 1 | 2 |' ,
2000
+ '| 3 | 4 |' ,
2001
+ '| 5 | 6 |' ,
2002
+ '| | |' ,
2003
+ '<!-- TBLFM: @>$>=@3 -->' ,
2004
+ '<!-- TBLFM: @>$1=(@>$2+3) -->' ,
2005
+ ] ) ;
2006
+ textEditor . setCursorPosition ( new Point ( 1 , 0 ) ) ;
2007
+ const tableEditor = new TableEditor ( textEditor ) ;
2008
+ const err = tableEditor . evaluateFormulas ( defaultOptions ) ;
2009
+ const pos = textEditor . getCursorPosition ( ) ;
2010
+ expect ( err ) . to . be . undefined ;
2011
+ expect ( pos . row ) . to . equal ( 1 ) ;
2012
+ expect ( pos . column ) . to . equal ( 0 ) ;
2013
+ expect ( textEditor . getSelectionRange ( ) ) . to . be . undefined ;
2014
+ expect ( textEditor . getLines ( ) ) . to . deep . equal ( [
2015
+ 'foo' ,
2016
+ '| A | B |' ,
2017
+ '| --- | --- |' ,
2018
+ '| 1 | 2 |' ,
2019
+ '| 3 | 4 |' ,
2020
+ '| 5 | 6 |' ,
2021
+ '| 7 | 4 |' ,
2022
+ '<!-- TBLFM: @>$>=@3 -->' ,
2023
+ '<!-- TBLFM: @>$1=(@>$2+3) -->' ,
2024
+ ] ) ;
2025
+ }
2026
+ } ) ;
1960
2027
} ) ;
1961
2028
} ) ;
0 commit comments