Skip to content

Commit

Permalink
no_lineno config optiopn (default: false)
Browse files Browse the repository at this point in the history
See #881
  • Loading branch information
Ruby authored and ko1 committed May 5, 2023
1 parent 3cf0253 commit 3becfa1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ config set no_color true
* `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
* `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
* `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false)

* CONTROL
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths
Expand Down Expand Up @@ -908,6 +909,8 @@ Attach mode:
'rdbg -A host port' tries to connect to host:port via TCP/IP.
Other options:
-v Show version number
--version Show version number and exit
-h, --help Print help
--util=NAME Utility mode (used by tools)
--stop-at-load Stop immediately when the debugging feature is loaded.
Expand Down
1 change: 1 addition & 0 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module DEBUGGER__
no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT", :bool, "false"],
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],

# control setting
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],
Expand Down
12 changes: 8 additions & 4 deletions lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,14 @@ def get_src(frame,
if file_lines = frame.file_lines
frame_line = frame.location.lineno - 1

lines = file_lines.map.with_index do |e, i|
cur = i == frame_line ? '=>' : ' '
line = colorize_dim('%4d|' % (i+1))
"#{cur}#{line} #{e}"
if CONFIG[:no_lineno]
lines = file_lines
else
lines = file_lines.map.with_index do |e, i|
cur = i == frame_line ? '=>' : ' '
line = colorize_dim('%4d|' % (i+1))
"#{cur}#{line} #{e}"
end
end

unless start_line
Expand Down
19 changes: 19 additions & 0 deletions test/console/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,23 @@ def test_debugger_takes_log_level_config_from_config_option
end
end
end

class NoLinenoTest < ConsoleTestCase
def program
<<~RUBY
1| a = :a
2| b = :b
3| c = :c
RUBY
end

def test_no_lineno
debug_code(program) do
type 'config set no_lineno true'
type 'list'
assert_no_line_text(/^\s*\d/)
type 'c'
end
end
end
end

0 comments on commit 3becfa1

Please sign in to comment.