Repository navigation
Tabs not recognized in practice tests. #548
Description
Activity
It is also not possible to use tabs when adding code snippets by hand.
sudo-adduser-jordan commented
on Jul 27, 2023 ContributorMore actionsI will look into this.
sudo-adduser-jordan commented
on Jul 27, 2023 ContributorMore actionsCan 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:
- Run a local instance of the App.
- Click "Add Snippet"
- Copy the code below & paste in the snippet to be added, & add the snippet:
#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.
- Click "Race", select "C++" and run. You should see the new code snippet. If not, refresh until you got the correct snippet.
- When you reach the tab character, pressing tab does nothing and you are stuck.
That's it. I'll create a PR with a fix later today.
sudo-adduser-jordan commented
on Jul 29, 2023 ContributorMore actionsThanks 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\tat 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!
- added a commit that references this issue
on Jul 30, 2023 sudo-adduser-jordan commented
on Jul 30, 2023 ContributorMore actionsThis will work. However, the
race-multiplayer.tsxfile 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", " ")insideadd-snippet-form.tsxwill 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 everyenter(), only once on insert.Tab will still not work inside the
/add-snippet-forminput.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.
Reacted by jordan and Harsha GopisettiHey @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