summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/utils/editor
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/debugger/src/utils/editor')
-rw-r--r--devtools/client/debugger/src/utils/editor/index.js44
-rw-r--r--devtools/client/debugger/src/utils/editor/tests/editor.spec.js12
2 files changed, 0 insertions, 56 deletions
diff --git a/devtools/client/debugger/src/utils/editor/index.js b/devtools/client/debugger/src/utils/editor/index.js
index e729388acf..3146581fdd 100644
--- a/devtools/client/debugger/src/utils/editor/index.js
+++ b/devtools/client/debugger/src/utils/editor/index.js
@@ -106,50 +106,6 @@ export function toSourceLine(sourceId, line) {
return line + 1;
}
-export function scrollToPosition(codeMirror, line, column) {
- // For all cases where these are on the first line and column,
- // avoid the possibly slow computation of cursor location on large bundles.
- if (!line && !column) {
- codeMirror.scrollTo(0, 0);
- return;
- }
-
- const { top, left } = codeMirror.charCoords({ line, ch: column }, "local");
-
- if (!isVisible(codeMirror, top, left)) {
- const scroller = codeMirror.getScrollerElement();
- const centeredX = Math.max(left - scroller.offsetWidth / 2, 0);
- const centeredY = Math.max(top - scroller.offsetHeight / 2, 0);
-
- codeMirror.scrollTo(centeredX, centeredY);
- }
-}
-
-function isVisible(codeMirror, top, left) {
- function withinBounds(x, min, max) {
- return x >= min && x <= max;
- }
-
- const scrollArea = codeMirror.getScrollInfo();
- const charWidth = codeMirror.defaultCharWidth();
- const fontHeight = codeMirror.defaultTextHeight();
- const { scrollTop, scrollLeft } = codeMirror.doc;
-
- const inXView = withinBounds(
- left,
- scrollLeft,
- scrollLeft + (scrollArea.clientWidth - 30) - charWidth
- );
-
- const inYView = withinBounds(
- top,
- scrollTop,
- scrollTop + scrollArea.clientHeight - fontHeight
- );
-
- return inXView && inYView;
-}
-
export function getLocationsInViewport(
{ codeMirror },
// Offset represents an allowance of characters or lines offscreen to improve
diff --git a/devtools/client/debugger/src/utils/editor/tests/editor.spec.js b/devtools/client/debugger/src/utils/editor/tests/editor.spec.js
index b3fcad17ff..3917adaba1 100644
--- a/devtools/client/debugger/src/utils/editor/tests/editor.spec.js
+++ b/devtools/client/debugger/src/utils/editor/tests/editor.spec.js
@@ -6,7 +6,6 @@ import {
toEditorLine,
toEditorPosition,
toSourceLine,
- scrollToPosition,
markText,
lineAtHeight,
getSourceLocationFromMouseEvent,
@@ -82,17 +81,6 @@ const codeMirror = {
const editor = { codeMirror };
-describe("scrollToPosition", () => {
- it("calls codemirror APIs charCoords, getScrollerElement, scrollTo", () => {
- scrollToPosition(codeMirror, 60, 123);
- expect(codeMirror.charCoords).toHaveBeenCalledWith(
- { line: 60, ch: 123 },
- "local"
- );
- expect(codeMirror.scrollTo).toHaveBeenCalledWith(0, 50);
- });
-});
-
describe("markText", () => {
it("calls codemirror API markText & returns marker", () => {
const loc = {