1212import * as I from "immutable" ;
1313
1414import makeRecord from "../utils/makeRecord" ;
15+ import { findEmptyLines } from "../utils/ast" ;
16+
1517import type { SymbolDeclarations , AstLocation } from "../workers/parser/types" ;
1618
1719import type { Map } from "immutable" ;
@@ -29,6 +31,7 @@ export type SourceMetaDataType = {
2931} ;
3032
3133export type SourceMetaDataMap = Map < string , SourceMetaDataType > ;
34+ export type PausePointsMap = Map < string , any > ;
3235
3336export type Preview =
3437 | { | updating : true | }
@@ -49,6 +52,7 @@ export type ASTState = {
4952 outOfScopeLocations : ?Array < AstLocation > ,
5053 inScopeLines : ?Array < Number > ,
5154 preview : Preview ,
55+ pausePoints : PausePointsMap ,
5256 sourceMetaData : SourceMetaDataMap
5357} ;
5458
@@ -60,6 +64,7 @@ export function initialASTState() {
6064 outOfScopeLocations : null ,
6165 inScopeLines : null ,
6266 preview : null ,
67+ pausePoints : I . Map ( ) ,
6368 sourceMetaData : I . Map ( )
6469 } : ASTState )
6570 ) ( ) ;
@@ -77,9 +82,14 @@ function update(
7782 }
7883 return state . setIn ( [ "symbols" , source . id ] , action . value ) ;
7984 }
80- case "SET_EMPTY_LINES" : {
81- const { source, emptyLines } = action ;
82- return state . setIn ( [ "emptyLines" , source . id ] , emptyLines ) ;
85+
86+ case "SET_PAUSE_POINTS" : {
87+ const { source, pausePoints } = action ;
88+ const emptyLines = findEmptyLines ( source , pausePoints ) ;
89+
90+ return state
91+ . setIn ( [ "pausePoints" , source . id ] , pausePoints )
92+ . setIn ( [ "emptyLines" , source . id ] , emptyLines ) ;
8393 }
8494
8595 case "OUT_OF_SCOPE_LOCATIONS" : {
@@ -170,15 +180,23 @@ export function isEmptyLineInSource(
170180 selectedSource : Source
171181) {
172182 const emptyLines = getEmptyLines ( state , selectedSource ) ;
173- return emptyLines . includes ( line ) ;
183+ return emptyLines && emptyLines . includes ( line ) ;
174184}
175185
176186export function getEmptyLines ( state : OuterState , source : Source ) {
177187 if ( ! source ) {
178- return [ ] ;
188+ return null ;
189+ }
190+
191+ return state . ast . getIn ( [ "emptyLines" , source . id ] ) ;
192+ }
193+
194+ export function getPausePoints ( state : OuterState , source : Source ) {
195+ if ( ! source ) {
196+ return null ;
179197 }
180198
181- return state . ast . getIn ( [ "emptyLines " , source . id ] ) || [ ] ;
199+ return state . ast . getIn ( [ "pausePoints " , source . id ] ) ;
182200}
183201
184202export function getOutOfScopeLocations ( state : OuterState ) {
0 commit comments