ethangreen-dev / lovely-injector

A runtime lua injector for games built with LÖVE
MIT License
79 stars 11 forks source link

Patches before/after a line of code are inserted on the same line #59

Closed stupxd closed 4 months ago

stupxd commented 4 months ago

If you have 2 patches like this

[[patches]] 
[patches.regex]
target = "main.lua"
pattern = '(?<indent>[\t ]*)_n\,_a\,_b\,_c\,_d\,_e\,_f = name\,a\,b\,c\,d\,e\,f'
position = "before"
payload = "-- Regex patch test"
line_prepend = '$indent'

[[patches]] 
[patches.pattern]
target = "main.lua"
pattern = '_n,_a,_b,_c,_d,_e,_f = name,a,b,c,d,e,f'
position = "before"
payload = "-- Pattern patch test"
match_indent = true

You will get a result like this image

I would expect 2nd patch to be on a new line

stupxd commented 4 months ago

Okay, seems to be a non issue, I guess, as regex patches don't create a new line ever (as seen in this example)

[[patches]] 
[patches.regex]
target = "main.lua"
pattern = '(?<indent>[\t ]*)_n\,_a\,_b\,_c\,_d\,_e\,_f = name\,a\,b\,c\,d\,e\,f'
position = "before"
payload = "-- Regex patch test"
line_prepend = '$indent'

[[patches]] 
[patches.regex]
target = "main.lua"
pattern = '[\t ]*-- Regex patch test'
position = "before"
payload = "-- Regex patch test but extra!"
line_prepend = '$indent'

image