|
253 | 253 | (let* ((breakpoints (haskell-debug-get-breakpoints))
|
254 | 254 | (context (haskell-debug-get-context))
|
255 | 255 | (string
|
256 |
| - (haskell-process-queue-sync-request |
257 |
| - (haskell-debug-process) |
258 |
| - (if expr |
259 |
| - (concat ":step " expr) |
260 |
| - ":step")))) |
| 256 | + (haskell-debug-trim-break-location |
| 257 | + (haskell-process-queue-sync-request |
| 258 | + (haskell-debug-process) |
| 259 | + (if expr |
| 260 | + (concat ":step " expr) |
| 261 | + ":step"))))) |
261 | 262 | (cond
|
262 | 263 | ((string= string "not stopped at a breakpoint\n")
|
263 | 264 | (if haskell-debug-bindings-cache
|
|
310 | 311 | (format "*debug:%s*"
|
311 | 312 | (haskell-session-name session)))
|
312 | 313 |
|
| 314 | +(defun haskell-debug-trim-break-location (string) |
| 315 | + "Remove trailing location of current break from output STRING if exists." |
| 316 | + (if-let ((i (string-match "^\\(... \\)?\\[[^]]+\\] $" string))) |
| 317 | + (substring string 0 i) |
| 318 | + string)) |
| 319 | + |
313 | 320 | (defun haskell-debug-get-breakpoints ()
|
314 | 321 | "Get the list of breakpoints currently set."
|
315 |
| - (let ((string (haskell-process-queue-sync-request |
316 |
| - (haskell-debug-process) |
317 |
| - ":show breaks"))) |
| 322 | + (let ((string (haskell-debug-trim-break-location |
| 323 | + (haskell-process-queue-sync-request |
| 324 | + (haskell-debug-process) |
| 325 | + ":show breaks")))) |
318 | 326 | (if (string= string "No active breakpoints.\n")
|
319 | 327 | (list)
|
320 | 328 | (mapcar #'haskell-debug-parse-break-point
|
321 | 329 | (haskell-debug-split-string string)))))
|
322 | 330 |
|
323 | 331 | (defun haskell-debug-get-modules ()
|
324 | 332 | "Get the list of modules currently set."
|
325 |
| - (let ((string (haskell-process-queue-sync-request |
326 |
| - (haskell-debug-process) |
327 |
| - ":show modules"))) |
| 333 | + (let ((string (haskell-debug-trim-break-location |
| 334 | + (haskell-process-queue-sync-request |
| 335 | + (haskell-debug-process) |
| 336 | + ":show modules")))) |
328 | 337 | (if (string= string "")
|
329 | 338 | (list)
|
330 | 339 | (mapcar #'haskell-debug-parse-module
|
331 | 340 | (haskell-debug-split-string string)))))
|
332 | 341 |
|
333 | 342 | (defun haskell-debug-get-context ()
|
334 | 343 | "Get the current context."
|
335 |
| - (let ((string (haskell-process-queue-sync-request |
336 |
| - (haskell-debug-process) |
337 |
| - ":show context"))) |
| 344 | + (let ((string (haskell-debug-trim-break-location |
| 345 | + (haskell-process-queue-sync-request |
| 346 | + (haskell-debug-process) |
| 347 | + ":show context")))) |
338 | 348 | (if (string= string "")
|
339 | 349 | nil
|
340 | 350 | (haskell-debug-parse-context string))))
|
341 | 351 |
|
342 | 352 | (defun haskell-debug-get-history ()
|
343 | 353 | "Get the step history."
|
344 |
| - (let ((string (haskell-process-queue-sync-request |
345 |
| - (haskell-debug-process) |
346 |
| - ":history"))) |
| 354 | + (let ((string (haskell-debug-trim-break-location |
| 355 | + (haskell-process-queue-sync-request |
| 356 | + (haskell-debug-process) |
| 357 | + ":history")))) |
347 | 358 | (if (or (string= string "")
|
348 | 359 | (string= string "Not stopped at a breakpoint\n"))
|
349 | 360 | nil
|
@@ -520,15 +531,13 @@ some old history, then display that."
|
520 | 531 | (point-max)))))))))
|
521 | 532 |
|
522 | 533 | (defun haskell-debug-parse-stopped-at (string)
|
523 |
| - "Parse the location stopped at from the given string. |
| 534 | + "Parse the location stopped at from the given STRING. |
524 | 535 |
|
525 |
| -For example: |
| 536 | +For examples: |
526 | 537 |
|
527 | 538 | Stopped at /home/foo/project/src/x.hs:6:25-36
|
528 |
| -
|
529 |
| -" |
530 |
| - (let ((index (string-match "Stopped at \\([^:]+\\):\\(.+\\)\n?" |
531 |
| - string))) |
| 539 | +Stopped in X.test, /home/foo/project/src/x.hs:6:25-36" |
| 540 | + (let ((index (string-match "Stopped \\(?:at\\|in [^,]+,\\) \\([^:]+\\):\\(.+\\)\n?" string))) |
532 | 541 | (when index
|
533 | 542 | (list :path (match-string 1 string)
|
534 | 543 | :span (haskell-debug-parse-span (match-string 2 string))
|
@@ -657,9 +666,10 @@ variances in source span notation."
|
657 | 666 |
|
658 | 667 | (defun haskell-debug-navigate (direction)
|
659 | 668 | "Navigate in DIRECTION \"back\" or \"forward\"."
|
660 |
| - (let ((string (haskell-process-queue-sync-request |
661 |
| - (haskell-debug-process) |
662 |
| - (concat ":" direction)))) |
| 669 | + (let ((string (haskell-debug-trim-break-location |
| 670 | + (haskell-process-queue-sync-request |
| 671 | + (haskell-debug-process) |
| 672 | + (concat ":" direction))))) |
663 | 673 | (let ((bindings (haskell-debug-parse-logged string)))
|
664 | 674 | (setq haskell-debug-bindings-cache
|
665 | 675 | bindings)
|
|
0 commit comments