Skip to content

Commit 0feaffa

Browse files
committed
Support case insensitive filename
On Windows and some other file systems, they support case insensitve filenames. This patch almost supports case insensitve file name on break command. Maybe we need more features to support case insensitve file names, so reports are welcome. fix #554
1 parent 3ef203d commit 0feaffa

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/debug/breakpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def try_activate
220220
nearest = nil # NearestISeq
221221

222222
ObjectSpace.each_iseq{|iseq|
223-
if (iseq.absolute_path || iseq.path) == self.path &&
223+
if DEBUGGER__.compare_path((iseq.absolute_path || iseq.path), self.path) &&
224224
iseq.first_lineno <= self.line &&
225225
iseq.type != :ensure # ensure iseq is copied (duplicated)
226226

lib/debug/session.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ def on_load iseq, src
15821582
end
15831583

15841584
pending_line_breakpoints.each do |_key, bp|
1585-
if bp.path == (iseq.absolute_path || iseq.path)
1585+
if DEBUGGER__.compare_path(bp.path, (iseq.absolute_path || iseq.path))
15861586
bp.try_activate
15871587
end
15881588
end
@@ -2107,6 +2107,20 @@ def self.step_in &b
21072107
yield
21082108
end
21092109

2110+
if File.identical?(__FILE__.upcase, __FILE__.downcase)
2111+
# For case insensitive file system (like Windows)
2112+
# Note that this check is not enough because case sensitive/insensitive is
2113+
# depend on the file system. So this check is only roughly estimation.
2114+
2115+
def self.compare_path(a, b)
2116+
a.downcase == b.downcase
2117+
end
2118+
else
2119+
def self.compare_path(a, b)
2120+
a == b
2121+
end
2122+
end
2123+
21102124
module ForkInterceptor
21112125
def fork(&given_block)
21122126
return super unless defined?(SESSION) && SESSION.active?

0 commit comments

Comments
 (0)