In this release, I focused on 2 issues that were quite different from each other (adobe/brackets#11862 & mozilla/brackets#596). I’m always is the lookout for new things to learn, so by choosing 2 different issues, I was able to accomplish my goal and delivered 2 fixes.
Adobe/Brackets#11862
Fixing this bug was really time consuming. Even though I didn’t write much code, I spent quite sometime thinking which file names are invalid and which are valid (I still don’t know if I’m right or not haha).
Here’s a scenario:
I have an important file named file<3.txt
. In Windows, this file name is invalid (Because of the char <
), but in macOS/Linux, this file name is valid! So… do I disallow file<3.txt
for every OS? Or just for Windows? Lets say I disallow it for Windows and I import a project that came from a macOS machine. If that project contained file<3.txt
, this file wont be imported. Do you see my conundrum? The user will be annoyed and clueless as to why the file is missing.
To avoid this issue, I disallowed <
in general (I’ve included other chars too).
This conundrum wasn’t even the main issue! The original issue was that users were able to “folder hop” by creating a file that contained a relative path in its name (Ex: A user created a file and named it “../../file2.txt"
). This allowed users to create files in unexpected places.
To fix this, I created a function that checked if the filename and file path where valid.
Bam! Now if the user gives a “bad” file name, Brackets will throw an error 🙂
Mozilla/Brackets#596
Now this was a really fun bug to fix. The idea is that, we want to allow the user to download a file or folder structure without the need to download the whole project. Here’s a demo:
First thing first. I had to create a new item named “Download” in the “right-click” menu that as you see if the gif above. Because we are working with locales, I had to create a new key
named CMD_FILE_DOWNLOAD
. I then attached a handler to the “Download” button so that once it’s clicked, it will trigger the `handleFileDownload()` function.
This function gets the path for the selected item in the file tree and either zips (if it’s a folder structurer) or download the file (if it’s a single file).
In conclusion, if you want to learn something, try it for yourself 🙂 Study what other functions are doing and debug it. You will learn more from debugging then staring at a piece of code.