Release 0.3 - Bug Fix

For release 0.3 the bug I found to work on is https://github.com/devtools-html/debugger.html/issues/6048. The bug was, in the source tree pane on the left side, when you try to make a certain directory a root it would just take the original root directory and set that as the root not the one we select. Just like any other bug the very first thing to do is to try and recreate the bug. Well technically its to get the environment set up.  I didn't really have much trouble in setting up the environment. I just followed the instructions provided in the README.md and everything worked right off the start.
Also while I was in the step of recreating the bug, I only had to try it once and it was very clear that the bug existed. This is not the same for some other bugs that I encountered. The next task was to find out where in the code the bug existed.  This I did it by using the Debugger plug-in that was available in VScode. Using it to find the <div></div> tag that holds the attributes for what happens when the bug is trying to be replicated. This gave me access to the file where the function was being called to do the changes. This was the SourceTree.js file inside src/components/PrimaryPanes.

        menuOptions.push({
          id: "node-set-directory-root",
          label: setDirectoryRootLabel,
          accesskey: setDirectoryRootKey,
          disabled: false,
          click: () => this.props.setProjectDirectoryRoot(path)
        });

This was the piece of code where everything was being set. But the issue wasn't here, the issue was with how the app was reading the string that was being passed through as the path. So I looked at where the setProjectDirectoryRoot() function was being initialized. This led me to the ui.js file located in src/actions/. While reading through the code in this file I came across the piece of code that did this.

export function setProjectDirectoryRoot(newRoot: string) {
  return ({ dispatch, getState }: ThunkArgs) => {
    const curRoot = getProjectDirectoryRoot(getState());
    if (newRoot && curRoot) {
      const temp = newRoot.split("/");
      temp.splice(0, 2);
      newRoot = `${curRoot}/${temp.join("/")}`;
    }

    dispatch({
      type: "SET_PROJECT_DIRECTORY_ROOT",
      url: newRoot
    });
  };
}

This is clearly where the bug was and fixing it was fairly simple. I simple just changed the condition of the if statement and ran the code and the bug seemed to be fixed. With that done I sent a PR to the main repository where it awaits approval.

Comments

Popular posts from this blog

Assignment 1 - DPS909

Release 0.2 - Bug fix

ECMA Script Testing