@@ -12,12 +12,15 @@ import { connect } from "react-redux";
1212import {
1313 getVisibleSelectedFrame ,
1414 getSelectedLocation ,
15- getSelectedSource
15+ getSelectedSource ,
16+ getPauseCommand
1617} from "../../selectors" ;
1718
1819import type { Frame , Location , SourceRecord } from "../../types" ;
20+ import type { Command } from "../../reducers/types" ;
1921
2022type Props = {
23+ pauseCommand : Command ,
2124 selectedFrame : Frame ,
2225 selectedLocation : Location ,
2326 selectedSource : SourceRecord
@@ -43,14 +46,47 @@ function isDocumentReady(selectedSource, selectedLocation) {
4346}
4447
4548export class HighlightLine extends PureComponent < Props > {
49+ isStepping : boolean = false ;
50+ previousEditorLine : ?number = null ;
51+
52+ shouldComponentUpdate ( nextProps : Props ) {
53+ const { selectedLocation, selectedSource } = nextProps ;
54+ return this . shouldSetHighlightLine ( selectedLocation , selectedSource ) ;
55+ }
56+
57+ shouldSetHighlightLine (
58+ selectedLocation : Location ,
59+ selectedSource : SourceRecord
60+ ) {
61+ const { sourceId , line } = selectedLocation ;
62+ const editorLine = toEditorLine ( sourceId , line ) ;
63+
64+ if ( ! isDocumentReady ( selectedSource , selectedLocation ) ) {
65+ return false ;
66+ }
67+
68+ if ( this . isStepping && editorLine === this . previousEditorLine ) {
69+ return false ;
70+ }
71+
72+ return true ;
73+ }
74+
4675 componentDidUpdate ( prevProps : Props ) {
47- const { selectedLocation, selectedFrame, selectedSource } = this . props ;
76+ const {
77+ pauseCommand,
78+ selectedLocation,
79+ selectedFrame,
80+ selectedSource
81+ } = this . props ;
82+ if ( pauseCommand ) {
83+ this . isStepping = true ;
84+ }
4885
4986 this . clearHighlightLine (
5087 prevProps . selectedLocation ,
5188 prevProps . selectedSource
5289 ) ;
53-
5490 this . setHighlightLine ( selectedLocation , selectedFrame , selectedSource ) ;
5591 }
5692
@@ -59,17 +95,18 @@ export class HighlightLine extends PureComponent<Props> {
5995 selectedFrame : Frame ,
6096 selectedSource : SourceRecord
6197 ) {
62- if ( ! isDocumentReady ( selectedSource , selectedLocation ) ) {
98+ const { sourceId, line } = selectedLocation ;
99+ if ( ! this . shouldSetHighlightLine ( selectedLocation , selectedSource ) ) {
63100 return ;
64101 }
65-
66- const { sourceId, line } = selectedLocation ;
102+ this . isStepping = false ;
103+ const editorLine = toEditorLine ( sourceId , line ) ;
104+ this . previousEditorLine = editorLine ;
67105
68106 if ( ! line || isDebugLine ( selectedFrame , selectedLocation ) ) {
69107 return ;
70108 }
71109
72- const editorLine = toEditorLine ( sourceId , line ) ;
73110 const doc = getDocument ( sourceId ) ;
74111 doc . addLineClass ( editorLine , "line" , "highlight-line" ) ;
75112 }
@@ -91,6 +128,7 @@ export class HighlightLine extends PureComponent<Props> {
91128}
92129
93130export default connect ( state => ( {
131+ pauseCommand : getPauseCommand ( state ) ,
94132 selectedFrame : getVisibleSelectedFrame ( state ) ,
95133 selectedLocation : getSelectedLocation ( state ) ,
96134 selectedSource : getSelectedSource ( state )
0 commit comments