Open RafaelZasas opened 1 year ago
It is also not possible to use tabs when adding code snippets by hand.
I will look into this.
Can you please include the snippet? A video would be extra helpful. Thank you
I notice the same thing, and I have a fix for it.
It's true that you cannot to use tabs when adding code snippets by hand. But if you copy and paste the snippet form somewhere else, the tab will be inserted. That's how I replicated the bug.
Can I take care of this issue or there's someone else already working at it?
Here's a step-by-step on how to reproduce the issue:
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
}
The code above has tab characters in it, so the snippet will be added with tab characters to the database.
That's it. I'll create a PR with a fix later today.
Thanks for the snippet. The /t needs to be stripped and replaced with whitespace before insert into the database. I would prefer to avoid editing the race logic.
Yep. I was thinking about these alternatives. The way I found to deal with the issue, is to tweak a little the race logic in packages/app/src/app/race/_components/race/race-practice.tsx
. But it turns out, the tweaks are really minimal: it's just about replicating some of the logic to deal with whitespaces in the beginning of a line, so it can also deal with \t
at the beginning of a line.
I suspect it's worth having the race practice to be able to deal with tabs, in case they end up in the database somehow. The idea of stripping the tabs before inserting into the database is good too. This would also give more consistency across different snippets, to avoid some coming with tabs and others with whitespaces.
It might be worth implementing both. I'll create a PR with the fix I did, so you can take a look. Let me know if this looks good!
@writeonlycode
This will work. However, the race-multiplayer.tsx
file will also have to be changed.
The snippets inside the database will not be uniform. This can make debugging accuracy more difficult.
A .replace("/t", " ")
inside add-snippet-form.tsx
will format the strings to be uniform upon insert into the database.
This way the race logic does not need to be edited or perform an extra step on every enter()
, only once on insert.
Tab will still not work inside the /add-snippet-form
input.
This issue should be reopened or a new issue should be created.
Good points. I'll explore further this issue, and I'll create another PRs once I implement these other tweaks.
Hey @writeonlycode could you please share updates, if any?
Description
Added a snippet of Go code which had a tab before the "fmt" import. When doing a practice run, I was not able to trigger the tab with a tab or spaces.
(optional) What browsers are you seeing the problem on?
Chrome
Code of Conduct