Skip to content

Commit 5f59734

Browse files
author
Ruby
committed
no_lineno config optiopn (default: false)
See #881
1 parent f4b4dda commit 5f59734

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ config set no_color true
476476
* `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
477477
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
478478
* `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
479+
* `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false)
479480

480481
* CONTROL
481482
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths
@@ -908,6 +909,8 @@ Attach mode:
908909
'rdbg -A host port' tries to connect to host:port via TCP/IP.
909910
910911
Other options:
912+
-v Show version number
913+
--version Show version number and exit
911914
-h, --help Print help
912915
--util=NAME Utility mode (used by tools)
913916
--stop-at-load Stop immediately when the debugging feature is loaded.

lib/debug/config.rb

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module DEBUGGER__
2121
no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT", :bool, "false"],
2222
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
2323
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
24+
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],
2425

2526
# control setting
2627
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],

lib/debug/thread_client.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,14 @@ def get_src(frame,
469469
if file_lines = frame.file_lines
470470
frame_line = frame.location.lineno - 1
471471

472-
lines = file_lines.map.with_index do |e, i|
473-
cur = i == frame_line ? '=>' : ' '
474-
line = colorize_dim('%4d|' % (i+1))
475-
"#{cur}#{line} #{e}"
472+
if CONFIG[:no_lineno]
473+
lines = file_lines
474+
else
475+
lines = file_lines.map.with_index do |e, i|
476+
cur = i == frame_line ? '=>' : ' '
477+
line = colorize_dim('%4d|' % (i+1))
478+
"#{cur}#{line} #{e}"
479+
end
476480
end
477481

478482
unless start_line

test/console/config_test.rb

+19
Original file line numberDiff line numberDiff line change
@@ -411,4 +411,23 @@ def test_debugger_takes_log_level_config_from_config_option
411411
end
412412
end
413413
end
414+
415+
class NoLinenoTest < ConsoleTestCase
416+
def program
417+
<<~RUBY
418+
1| a = :a
419+
2| b = :b
420+
3| c = :c
421+
RUBY
422+
end
423+
424+
def test_no_lineno
425+
debug_code(program) do
426+
type 'config set no_lineno true'
427+
type 'list'
428+
assert_no_line_text(/^\s*\d/)
429+
type 'c'
430+
end
431+
end
432+
end
414433
end

0 commit comments

Comments
 (0)