Skip to content

added link to VSCode plugin#5

Merged
mschenk42 merged 1 commit intogit-time-metric:masterfrom
nexus-uw:patch-1
Jul 26, 2016
Merged

added link to VSCode plugin#5
mschenk42 merged 1 commit intogit-time-metric:masterfrom
nexus-uw:patch-1

Conversation

@nexus-uw
Copy link
Copy Markdown
Contributor

Hello,

I just released a gtm plugin for Visual Studio Code. It would great if it was included in the list of editor plugins.

All the best,
Simon R

@mschenk42
Copy link
Copy Markdown
Member

mschenk42 commented Jul 24, 2016

Thank you for taking the time to create a plugin. I appreciate the help here. I was just about to embark on creating a Visual Code plugin.

I noticed there are a few things you need to add to allow gtm to track accurately.

For events, you will need to subscribe to more than the onDidSaveTextDocument event. I would also tap into these events:

vscode.window.onDidChangeTextEditorSelection
vscode.window.onDidChangeActiveTextEditor

When recording events, to reduce the frequency of updates you can define your logic to allow updates only if the file name has changed from the last recorded file name or it's been more than 30 seconds.

Here's some examples of how to do that.
Atom Plugin
Sublime Plugin
Vim Plugin

I also think it would be great to add the work in process (uncommitted) time to the status bar.

If you want I can help you with this and testing. Just let me know.

Once we get this updated, we can definitely add your plugin to the README.

Thanks again for your help.

@nexus-uw
Copy link
Copy Markdown
Contributor Author

HI Michael,

I have created a new PR( nexus-uw/vscode-gtm#1) that adds the additional editor events you mentioned as well as the reduced frequency of updates to gtm. Could you take a look and tell me what you think?

I'll get around to the status bar text latter this week (hopefully). I'm guessing it is just displaying the result of gtm status -total-only every-time gtm is updated?

All the best,
Simon

PS. the atom plugin appears to implement a different update frequency logic than the sublime + vim plugins. but I could be wrong since I am not well versed in coffee-script.

@gradymke
Copy link
Copy Markdown
Member

Hey Simon,

Yes, you can get the data you need from that command. As of gtm-1.0-beta.6 (I think), the gtm record --status filename command will both record an event as well as return the text you want, so you don't have to do multiple calls.

Can you explain what you found different in the atom plugin? It's very possible it's different, as it had a different author than the other two, but the overall logic should be the same.

@nexus-uw
Copy link
Copy Markdown
Contributor Author

Hi Brandon,

that flag works great. I created another PR that will check that gtm is at least beta 6, nexus-uw/vscode-gtm#3 (nexus-uw/vscode-gtm@2126320, more specifically) . feel free to take a look

The atom plugin has up to 2 calls to log-event per each subscribed editor event:

  • the event's file
  • and the previous file name, if it differs from the current event's file name

@gradymke
Copy link
Copy Markdown
Member

Oh yeah, that's a good point, I do that... I'm not sure if it's necessary, honestly. My thought was that I wanted to log one last event on the last file before switching to the new file. @mschenk42, can you clarify if that logic is correct or if I might be causing invalid timings by doing that?

@mschenk42
Copy link
Copy Markdown
Member

Simon,

I did some testing on your sub-to-more-events branch on my Mac. It's finding gtm and firing based on the new events. Looking good.

You need to make a small change in regards to when you update the last file and last update time. Just move it within the if.

    if (fileName !== lastSavedFileName || (now.getTime() - lastUpdated.getTime()) >= MIN_UPDATE_FREQUENCE_MS) {
      run_cmd('gtm', ['record', lastSavedFileName], () => { });
      lastSavedFileName = fileName;
      lastUpdated = now;
    }
  }

@mschenk42
Copy link
Copy Markdown
Member

@gradymke to answer your question, I wouldn't log the file you moved away from, because it may give more time to the last file than it deserves.

So if I'm understanding this correctly below, I'd remove the @logevent(@lastFile)

      if filename != @lastFile || duration >= @updateDuration || force
        if filename != @lastFile
          @logEvent(@lastFile)

        @logEvent(filename)

        @lastFile = filename
        @lastUpdate = now

@nexus-uw
Copy link
Copy Markdown
Contributor Author

@mschenk42, I appended your suggestion to the PR, and merged it in.

@mschenk42 mschenk42 merged commit aba6dd7 into git-time-metric:master Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants