How to get the current line edited of a script

I’m making a plugin that responds to command such as while1 and replaces it with while task.wait(1) do, but there’s one issue, it only loop until the second line instead of throughly looping the script

If you still don’t know what i’m talking about, this

line 1: while1 -- works
line 2: while4 -- works
line 3: while1 -- doesn't work at all

turns into (i deleted the end) temporarely)

line 1: while task.wait(1) do
line 2: while task.wait(4) do
line 3: while1

I tried to do something like this but to no avail

local previousSource = src.Source
    local source = src.Source
    local lines = source:split("\n")
    local line, index
    for i, x in previousSource:split("\n")
        for j, y in lines do
            if x ~= y then
               line = y
               index = x
    print(line, index)
    previousSource = src.Source

At this point i gave up and yet here we are.
Like the title says, How do i get the current line edited in a script

There isn’t any built in method for this but you could compare the previous verison of the source to the new one and see any changes and makes fixes depending on that.

But otherwise this is a useful idea and I wish you luck making it.

Bumping isn’t going to do you any good. There just aren’t that many of us and we all have a life. It looks like you need to not break the loop, instead add all the changes to a table. Otherwise the loop stops after the first change detected.

Ah; i see; that’s why it stops at line 2; i feel so dumb right now as soon i realized that