The best way to find bugs is to change code.

Issue: https://github.com/mozilla/thimble.mozilla.org/issues/1745

Pull request:

https://github.com/mozilla/brackets/pull/650

https://github.com/mozilla/thimble.mozilla.org/pull/1891

 

Issue introduction:

On this issue, they want to allow users to choose if editing SVG file in a text editor.

097d6f28-f42d-11e6-95fd-c60da32f8908.png

 

Because of the previous experience, it is easy for me to add a feature about preference manager. However, it is not very easy.

  1. Merge conflict

Because another programmer adds a toggle on the same lines when I send a pull request, it shows merge conflict. This conflict mess up HTML format, so I merge upstream master to my branch to fix the conflict locally.

2. Another bug.

One of the good ways to find bugs is to change the code. When users add a non-text file, they cannot open the file immediately. They have to add another new file first, or they need to refresh the page. Because of this bug, my new feature doesn’t work very well.

8435529c-1bdf-11e7-8346-af40180571bb.gif

 

I spent on this issue one month, and I realized this code.

 function getOpenDocumentForPath(fullPath) {
   var id;

   // Need to walk all open documents and check for matching path. We can't
   // use getFileForPath(fullPath).id since the file it returns won't match
   // an Untitled document's InMemoryFile.
   for (id in _openDocuments) {
     if (_openDocuments.hasOwnProperty(id)) {
         if (_openDocuments[id].file.fullPath === fullPath) {
           return _openDocuments[id];
         }
       }
     }
   return null;
 }

If the bug happens, it returns null. if I can open as a text editor, it returns the _openDocument.

I use many ways to try to understand what causes this difference.  When I have an idea, I write it down. After I get home, I try to fix it with this idea. For example, I open 2 browsers and debug it line by line to see the difference. However, there are a lot of lines running when I add a file. Another attempt is I change a isImage function, and set it to always return false.  The bug is still happening. Finally, I realize that this bug may happen on other files type.

Finally, thanks for my professor. He fixes this bug, and my feature can be merged.

The best way to find bugs is to change the code. When we do some tests, we find another bug such as memory leak.  To see more, click here

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s