This is a basic VS Code extension, that will allow the users to view the username of the last editor of each line of code. As in a code base, a team of multiple programmers work simultaneously, it is important to note what changes were made and who made them.
- Install Node.js, if not already installed.
- Install the Yeoman extension generator. (use sudo if there are any permission issues.)
- Create a new folder and run the ‘yo code’ command to generate a basic structure for the extension. And select the parameteres for the extension-
- Type of extension- New Extension (TypeScript)- This gives a basic structure for our extension which we will modify.
- Name- LastEditor
- Identifier- lasteditor
- Description- This extension will allow the users to view the username of the last editor of each line of code. As in a code base, a team of multiple programmers work simultaneously, it is important to note what changes were made and who made them.
- Initialise Git Repo- Yes.
- Bundle the Code with webpack- For a basic extension, we don’t need to bundle the code. That is only required when we have a complex extension having multiple dependencies.
- Package Manager- We will be using the npm manager.
- The Basic structure of the extension is created in the original folder.
- Now edit the extension.ts file in the src directory and create the function to display the name of the author for each line of code.
- I've used the git interface approach, which basically makes use of the Git Blame Info for this. Here, we use the data stored in git about who committed a specific line of code.
- Edit the package.json file to add the respective devDependencies, commands and build scripts for execution. Make sure to add the correct name of the command for activation of the extension and also the correct file path.
- Install the VSIX file attached in the repository, directly into your VS Code Editor.
- Select the line you want to know the last author of.
- Open the Command Palette (cmd+shift+P / ctrl+shift+P) and search for the Command- "Show Last Editor" and click it.
- To test the extension, I firstly opened the very own files of this extension and saw myself as the user.
- Then I cloned a public github repo and tried to see it's authors.