astuder / lightroom-map-fix

Fixing the Map module in Lightroom Classic
125 stars 17 forks source link

Replace function only replaces first occurence of string #42

Closed astuder closed 1 year ago

astuder commented 1 year ago

In the current implementation of patchluastr.py only the first occurrence of the search string within a Lua string is replaced. The expected behavior is that all occurrences are replaced.

Pitfall: avoid replacing string in replacement.

Maybe use Python string.replace instead of doing it manually.

Relevant code: https://github.com/astuder/lightroom-map-fix/blob/5d7bdc0d988e4b6f67857c6ac3840d129b97ada5/patchluastr.py#L85

astuder commented 1 year ago

Hmm, we're already using string.replace.. so something else is amiss. https://github.com/astuder/lightroom-map-fix/blob/5d7bdc0d988e4b6f67857c6ac3840d129b97ada5/patchluastr.py#L115

astuder commented 1 year ago

Doh! It works as expected, but the console output is misleading, mentioning only one replacement per Lua string.