diff options
Diffstat (limited to 'devtools/client/debugger/src/utils/editor/get-token-location.js')
-rw-r--r-- | devtools/client/debugger/src/utils/editor/get-token-location.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/utils/editor/get-token-location.js b/devtools/client/debugger/src/utils/editor/get-token-location.js new file mode 100644 index 0000000000..2642066051 --- /dev/null +++ b/devtools/client/debugger/src/utils/editor/get-token-location.js @@ -0,0 +1,16 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +export function getTokenLocation(codeMirror, tokenEl) { + const { left, top, width, height } = tokenEl.getBoundingClientRect(); + const { line, ch } = codeMirror.coordsChar({ + left: left + width / 2, + top: top + height / 2, + }); + + return { + line: line + 1, + column: ch, + }; +} |