Browse Source

Fix #185 Set breakpoints location to the correct column

Setting breakpoints at column 0 does not work on minified files when line breaks
are discarded.

* indium-client.el (indium-client-add-breakpoint): Send the column as part of
the payload.
* indium-structs.el (indium-breakpoint-location): Ensure that the column of a
breakpoint is at the first indent of the line.
* server/adapters/cdp/helpers.js (resolveFileLocationWithSOurceMaps):
* server/adapters/cdp/index.js (registerBreakpoint): Take the column argument
into account.
drone
Nicolas Petton 3 years ago
parent
commit
42cf3f1bda
No known key found for this signature in database GPG Key ID: E8BCD7866AFCF978
4 changed files with 10 additions and 7 deletions
  1. +4
    -2
      indium-client.el
  2. +1
    -0
      indium-structs.el
  3. +2
    -2
      server/adapters/cdp/helpers.js
  4. +3
    -3
      server/adapters/cdp/index.js

+ 4
- 2
indium-client.el View File

@ -207,12 +207,14 @@ When non-nil, evaluate CALLBACK with the result."
(let* ((id (indium-breakpoint-id breakpoint))
(location (indium-breakpoint-location breakpoint))
(file (indium-location-file location))
(line (indium-location-line location)))
(line (indium-location-line location))
(column (indium-location-column location)))
(indium-client-send `((type . "runtime")
(payload . ((action . "addBreakpoint")
(id . ,id)
(file . ,(indium-client--convert-path file))
(line . ,line)))))))
(line . ,line)
(column . ,column)))))))
(defun indium-client-remove-breakpoint (breakpoint)
"Request the removal of BREAKPOINT."


+ 1
- 0
indium-structs.el View File

@ -78,6 +78,7 @@
(save-excursion
(goto-char (point-min))
(forward-char pos)
(back-to-indentation)
(indium-location-at-point)))))
(defun indium-breakpoint-buffer (breakpoint)


+ 2
- 2
server/adapters/cdp/helpers.js View File

@ -157,13 +157,13 @@ const resolveFileLocation = async (location, conf, scripts = {}) => {
|| resolveFileLocationWithScriptUrls(location, conf, scripts);
};
const resolveFileLocationWithSourceMaps = async ({ file, line }, conf, scripts) => {
const resolveFileLocationWithSourceMaps = async ({ file, line, column }, conf, scripts) => {
for (let script of Object.values(scripts)) {
let sourcemap = await getScriptSourceMap(script, conf);
if (sourcemap) {
let position = sourcemap.generatedPositionFor({
source: file, line, column: 0
source: file, line, column
});
if (position.line) {


+ 3
- 3
server/adapters/cdp/index.js View File

@ -271,9 +271,9 @@ const registerBreakpoint = async breakpoint => {
return;
}
let { url, line } = urlLocation;
let { url, line, column } = urlLocation;
console.log(`Setting breakpoint to ${url}:${line}`);
console.log(`Setting breakpoint to ${url}:${line}:${column}`);
let result = await state.client.Debugger.setBreakpointByUrl({
url,
@ -281,7 +281,7 @@ const registerBreakpoint = async breakpoint => {
// lines are 1-based in NPM's source-map package and Emacs, but 0-based
// in the CDP.
lineNumber: --line,
columnNumber: 0
columnNumber: column
});
let { locations: [ location ], breakpointId } = result;


Loading…
Cancel
Save