Skip to content

Commit 6bec44b

Browse files
authored
strip_gensym: handle unicode correctly (#129)
fixes JuliaDebug/Cthulhu.jl#583
1 parent 923fe46 commit 6bec44b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ function strip_gensym(str::AbstractString)
201201
if startswith(str, '#')
202202
idx = findnext('#', str, 2)
203203
if idx !== nothing
204-
return Symbol(str[2:idx-1])
204+
return Symbol(str[2:prevind(str, idx)])
205205
end
206206
end
207-
endswith(str, "##kw") && return Symbol(str[1:end-4])
207+
endswith(str, "##kw") && return Symbol(str[1:prevind(str, end-3)])
208208
return Symbol(str)
209209
end
210210

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,8 @@ end
432432
body, _ = CodeTracking.definition(String, which(diffminmax, (Any,)))
433433
@test body == "diffminmax((min, max)) = max - min"
434434
end
435+
436+
@testset "strip_gensym with unicode" begin
437+
@test CodeTracking.strip_gensym("#𝓔′#90") == :𝓔′
438+
@test CodeTracking.strip_gensym("𝓔′##kw") == :𝓔′
439+
end

0 commit comments

Comments
 (0)