Browse Source

Add "C-c b e" to edit breakpoint condition at point

workspaces
Damien Cassou 3 years ago
parent
commit
26485240ac
No known key found for this signature in database GPG Key ID: A7123815F5DCE914
5 changed files with 37 additions and 1 deletions
  1. +3
    -0
      doc/Indium.texi
  2. +14
    -0
      indium-breakpoint.el
  3. +6
    -0
      indium-interaction.el
  4. +1
    -0
      sphinx-doc/code-evaluation.rst
  5. +13
    -1
      test/unit/indium-breakpoint-test.el

+ 3
- 0
doc/Indium.texi View File

@ -633,6 +633,9 @@ You need to first make sure that Indium is set up correctly to use local files
@item
@code{C-c b K}: Remove all breakpoints from the current buffer
@item
@code{C-c b e}: Edit condition of a breakpoint
@item
@code{C-c b l}: List all breakpoints and easily jump to any breakpoint


+ 14
- 0
indium-breakpoint.el View File

@ -45,6 +45,20 @@ CONDITION is true."
(indium-breakpoint-added id ov))
condition))))
(defun indium-breakpoint-edit-condition ()
"Edit condition of breakpoint at point."
(let* ((breakpoint (indium-backend-get-breakpoint (indium-breakpoint-id-at-point)))
(old-condition (map-elt breakpoint 'condition))
(new-condition (read-from-minibuffer
(format "Breakpoint condition (%s): " old-condition)
nil nil nil nil old-condition))
(new-condition (if (string-empty-p new-condition)
old-condition
new-condition)))
(map-put breakpoint 'condition new-condition)
(indium-breakpoint-remove)
(indium-breakpoint-add new-condition)))
(defun indium-breakpoint-remove ()
"Remove the breakpoint from the current line."
(if-let ((id (indium-breakpoint-id-at-point)))


+ 6
- 0
indium-interaction.el View File

@ -130,6 +130,11 @@ If PRINT is non-nil, print the output into the current buffer."
(interactive)
(indium-breakpoint-add (read-from-minibuffer "Breakpoint condition: ")))
(defun indium-edit-breakpoint-condition ()
"Edit the condition of breakpoint at point."
(interactive)
(indium-breakpoint-edit-condition))
(defun indium-remove-breakpoint ()
"Remove the breakpoint at point."
(interactive)
@ -223,6 +228,7 @@ hitting a breakpoint."
(define-key map (kbd "C-c C-k") #'indium-update-script-source)
(define-key map (kbd "C-c b b") #'indium-add-breakpoint)
(define-key map (kbd "C-c b c") #'indium-add-conditional-breakpoint)
(define-key map (kbd "C-c b e") #'indium-edit-breakpoint-condition)
(define-key map (kbd "C-c b k") #'indium-remove-breakpoint)
(define-key map (kbd "C-c b K") #'indium-remove-all-breakpoints-from-buffer)
(define-key map (kbd "C-c b a") #'indium-activate-breakpoints)


+ 1
- 0
sphinx-doc/code-evaluation.rst View File

@ -40,6 +40,7 @@ You need to first make sure that Indium is set up correctly to use local files
- ``C-c b c``: Add a conditional breakpoint
- ``C-c b k``: Remove a breakpoint
- ``C-c b K``: Remove all breakpoints from the current buffer
- ``C-c b e``: Edit condition of a breakpoint
- ``C-c b l``: List all breakpoints and easily jump to any breakpoint
- ``C-c b d``: Deactivate all breakpoints (the runtime won't pause when hitting a breakpoint)
- ``C-c b a``: Activate all breakpoints (it has no effect if breakpoints have not been deactivated)


+ 13
- 1
test/unit/indium-breakpoint-test.el View File

@ -37,7 +37,19 @@
(goto-char (point-min))
(expect (indium-breakpoint-on-current-line-p) :to-be nil)
(indium-breakpoint--put-icon)
(expect (indium-breakpoint-on-current-line-p) :to-be-truthy))))
(expect (indium-breakpoint-on-current-line-p) :to-be-truthy)))
(it "can edit a breakpoint on the current line"
(spy-on #'read-from-minibuffer :and-return-value "new condition")
(spy-on #'indium-breakpoint-remove)
(spy-on #'indium-breakpoint-add)
(with-js2-buffer "let a = 1;"
(goto-char (point-min))
(indium-breakpoint-add "old condition")
(indium-breakpoint-edit-condition)
(expect #'read-from-minibuffer :to-have-been-called)
(expect #'indium-breakpoint-remove :to-have-been-called)
(expect #'indium-breakpoint-add :to-have-been-called-with "new condition"))))
(describe "Breakpoint duplication handling"
(it "can add a breakpoint multiple times on the same line without duplicating it"


Loading…
Cancel
Save