New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix padWithLinebreaks by switching to upstream FAIAP #1194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to note that this will update this library for any other addon which uses it. This may or may not have unintended side effects.
Did people actually complain about this? |
yes people notice extra ever increasing line breaks, but this looks strange, the code explicitly checks whether the code ends in \n\n, and only adds those if they are missing so this should only ever add 2 |
I'll see if i can come with a fix to the function.
|
padWithLinebreaks restored and fixed to handle indented line breaks |
if stringbyte(code, len) == linebreak then | ||
if stringbyte(code, len - 1) == linebreak then | ||
return code, false | ||
local len = stringlen(code) + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am nitpicking, but this number doesn’t really represent the length of the string anymore.
local breakfound = 0 | ||
while true do | ||
len = len - 1 | ||
local byte = stringbyte(code, len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might cause issues if the code is < 2 bytes long. I’m not sure how stringbyte handles inputs < 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simple fix would be to check if the string is extremely short, and handle that as a special case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's working as intended on an empty custom code editbox
moved byte variable out of the loop to save allocation time
So this looks like it is indeed a bug in that library and the fix is good. But, it's a library and we overwriting everyone elses version if we ship this. @Stanzilla how do we proceed ? |
So I don't actually know of any other addon that uses it and there is no repo for it either, it was just passed on as a "snippet" over the years. So I'd say we can roll with it and see if anyone complains, if they do, we can change the name of the lib. |
Hmm, that's not ideal, but okay let's do that. |
The simple answer would be to just make this fork local. Then we can update it as needed without worrying about conflicts. If somebody is depending on this library to be delivered publically along with WeakAuras, then they deserve a smack in the nose :) |
We just discovered that WoWLua, Plater and Details use it so yeah |
Maybe we should just make an official repo for it and let the other authors know |
That’s fine with me. Do we have permission to republish like that? |
Details & Plater use the same version as we do, with the fix on getCaretPos(editbox) we did |
Hey @grizzm0 what's the license on AllIndentsAndPurposes? |
@Stanzilla Tagged the wrong person? ;) |
@grizzm0 certainly possible, I searched for the email address on GitHub and you came up, sorry! kristofer.karlsson vs karlsson.kristofer >.< |
@Stanzilla No worries. Always wondered who managed to steal that email from me! :o I even got an odd spelling of Kristofer. ;) |
@spkrka I believe you are the original author of ForAllIndentsAndPurposes, right? |
Yes, that's me (but on my personal account @krka ) Here's the original repository: https://github.com/krka/ForAllIndentsAndPurposes Code change looks reasonable, and I can take a deeper look later. A simple thing to change could be to replace (Sorry about the name steal @grizzm0 but I suspect I was in fact born before you :-) ) |
I've made the following PR in the original repository now: krka/ForAllIndentsAndPurposes#4 |
Description
Fix adding trailing line break when editing custom code