Skip to content

Commit

Permalink
Highlight ruby debugger lines appropriately
Browse files Browse the repository at this point in the history
Fixes #16357

The change expands the matching regex to only highlight lines where the debugger
is the first word on a line.

The intended behavior is to highlight lines that are calling a ruby debugger.
The purpose is to warn developers that might push code to production
with a debugger enabled. The change expands the matching regex to only highlight
lines where the debugger is the first word on a line.

However, there are cases in which the regex is highlighting lines as a
false-positive. I first noticed this in my `Gemfile` when it was highlighting the
line below:

```ruby
gem 'pry-byebug'
```

Other cases include: commented lines and defined function names that match a known
debugger.

See below for cases in which the line should and should not be highlighted.

```ruby

class Test
  # This line below should not be highlighted
  def byebug
    byebug # this line should be highlighted
    # byebug This comment shouldn't be highlighted

    binding.irb # this line should be highlighted
    # binding.irb this line should not be highlighted

    binding.pry # this line should be highlighted
    # binding.pry this line should not be highlighted
  end
end
```
  • Loading branch information
bostonaholic authored and smile13241324 committed May 11, 2024
1 parent 4252274 commit 9e03b69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.develop
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ the [[file:CHANGELOG.org][CHANGELOG.org]] file.
* Release 0.300.x
** 0.300.0
*** Hot new feature
- Highlight ruby debugger lines appropriately
- Add support for Android emacs.
- Extensive use of lazy loading of packages and other tricks to reduce Spacemacs
startup time. In most cases you should see a noticable improvement in load
Expand Down
6 changes: 3 additions & 3 deletions layers/+lang/ruby/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ Called interactively it prompts for a directory."
"Highlight break point lines."
(interactive)
(when ruby-highlight-debugger-keywords
(highlight-lines-matching-regexp "byebug")
(highlight-lines-matching-regexp "binding.irb")
(highlight-lines-matching-regexp "binding.pry")))
(highlight-lines-matching-regexp "^\s*byebug")
(highlight-lines-matching-regexp "^\s*binding.irb")
(highlight-lines-matching-regexp "^\s*binding.pry")))


;; Insert text
Expand Down

0 comments on commit 9e03b69

Please sign in to comment.