Skip to content

Conversation

@Cheatoid
Copy link
Contributor

@Cheatoid Cheatoid commented Jan 19, 2026

Modified to enforce directives be at the beginning of the line, while still allowing leading whitespace

So for example, if you have:

--@client
print("--@server") --@name not allowed here anymore
         --@model however/this/is/fine.mdl

This PR solves it simply by prepending a newline and allowing leading whitespace, therefore the "--@server" and --@name would no longer match in the above case.

Modified to enforce directives be at the beginning of the line, while still allowing leading whitespace
@thegrb93
Copy link
Owner

thegrb93 commented Jan 19, 2026

Idk, what if someone likes to do stuff like require("mylib.txt") --@include mylib.txt? Their chips will be broken.

@Cheatoid
Copy link
Contributor Author

Cheatoid commented Jan 19, 2026

Idk, what if someone likes to do stuff like require("mylib.txt") --@include mylib.txt? Their chips will be broken.

Yes, PR is a breaking change in that regard.
Maybe just introduce a new directive to fix that once and for all.

--@import mylib.txt

and it would expand into what you've posted, then we can move on. Want me add that?
They can simply regex-replace it to migrate/fix their scripts if they really have such.
I think you shouldn't have directives embedded together with the actual code on the same line in the first place.

@thegrb93
Copy link
Owner

I don't think there's a good general way to implement that. Special cases like this exist libs.mylib = require("mylib.txt") --@include mylib.txt. I guess you could do libs.mylib = --@require mylib.txt if the changes in this PR are reverted.

@thegrb93
Copy link
Owner

thegrb93 commented Jan 19, 2026

I do think the directive matching could be improved if the iterator is changed to SF.GetLines and better matching is done per line though. I would want to test the performance difference on a big file to make sure it isn't too costly though.

@thegrb93 thegrb93 closed this Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants