Bug 1533549 - Bug 1533547 - Column Breakpoints are not visible when reloading. r=loganfsmyth
authorJason Laster <jlaster@mozilla.com>
Fri, 08 Mar 2019 20:38:17 +0000
changeset 521212 d1d79a310137
parent 521211 bf12f5e8abad
child 521213 8feadb1f48f2
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1533549, 1533547
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533549 - Bug 1533547 - Column Breakpoints are not visible when reloading. r=loganfsmyth Differential Revision: https://phabricator.services.mozilla.com/D22607
devtools/client/debugger/new/src/components/Editor/index.js
devtools/client/debugger/new/src/selectors/visibleColumnBreakpoints.js
devtools/client/debugger/new/src/utils/editor/index.js
--- a/devtools/client/debugger/new/src/components/Editor/index.js
+++ b/devtools/client/debugger/new/src/components/Editor/index.js
@@ -200,17 +200,16 @@ class Editor extends PureComponent<Props
     } else {
       codeMirrorWrapper.addEventListener("contextmenu", event =>
         this.openMenu(event)
       );
     }
 
     codeMirror.on("scroll", this.onEditorScroll);
     this.onEditorScroll();
-
     this.setState({ editor });
     return editor;
   }
 
   componentDidMount() {
     const { shortcuts } = this.context;
 
     const searchAgainKey = L10N.getStr("sourceSearch.search.again.key2");
@@ -266,16 +265,20 @@ class Editor extends PureComponent<Props
       if (!this.state.editor) {
         const editor = this.setupEditor();
         updateDocument(editor, selectedSource);
       } else {
         this.setText(this.props);
         this.setSize(this.props);
       }
     }
+
+    if (prevProps.selectedSource != selectedSource) {
+      this.props.updateViewport();
+    }
   }
 
   getCurrentLine() {
     const { codeMirror } = this.state.editor;
     const { selectedSource } = this.props;
     if (!selectedSource) {
       return;
     }
--- a/devtools/client/debugger/new/src/selectors/visibleColumnBreakpoints.js
+++ b/devtools/client/debugger/new/src/selectors/visibleColumnBreakpoints.js
@@ -39,20 +39,16 @@ function contains(location: PartialPosit
     location.line >= range.start.line &&
     location.line <= range.end.line &&
     (!location.column ||
       (location.column >= range.start.column &&
         location.column <= range.end.column))
   );
 }
 
-function inViewport(viewport, location) {
-  return viewport && contains(location, viewport);
-}
-
 function groupBreakpoints(breakpoints, selectedSource) {
   if (!breakpoints) {
     return {};
   }
   const map: any = groupBy(
     breakpoints,
     breakpoint => getSelectedLocation(breakpoint, selectedSource).line
   );
@@ -92,17 +88,17 @@ function filterByLineCount(positions, se
     breakpoint =>
       lineCount[getSelectedLocation(breakpoint, selectedSource).line] > 1
   );
 }
 
 function filterVisible(positions, selectedSource, viewport) {
   return positions.filter(columnBreakpoint => {
     const location = getSelectedLocation(columnBreakpoint, selectedSource);
-    return inViewport(viewport, location);
+    return viewport && contains(location, viewport);
   });
 }
 
 function filterByBreakpoints(positions, selectedSource, breakpointMap) {
   return positions.filter(position => {
     const location = getSelectedLocation(position, selectedSource);
     return breakpointMap[location.line];
   });
--- a/devtools/client/debugger/new/src/utils/editor/index.js
+++ b/devtools/client/debugger/new/src/utils/editor/index.js
@@ -157,16 +157,22 @@ function isVisible(codeMirror: any, top:
     scrollTop + scrollArea.clientHeight - fontHeight
   );
 
   return inXView && inYView;
 }
 
 export function getLocationsInViewport({ codeMirror }: Object) {
   // Get scroll position
+  if (!codeMirror) {
+    return {
+      start: { line: 0, column: 0 },
+      end: { line: 0, column: 0 },
+    };
+  }
   const charWidth = codeMirror.defaultCharWidth();
   const scrollArea = codeMirror.getScrollInfo();
   const { scrollLeft } = codeMirror.doc;
   const rect = codeMirror.getWrapperElement().getBoundingClientRect();
   const topVisibleLine = codeMirror.lineAtHeight(rect.top, "window");
   const bottomVisibleLine = codeMirror.lineAtHeight(rect.bottom, "window");
 
   const leftColumn = Math.floor(scrollLeft > 0 ? scrollLeft / charWidth : 0);