Skip to content

Conversation

@tomglynch
Copy link

Hi @lostintangent, hope you're doing well. GitDoc is a great tool, but I wanted a feature to have it always show the status bar icon rather than it disappearing when disabled (#89 ). In fixing that, I also ended up fixing #90 as it affected the icons being shown. I handled icons for matching the File Patterns too. Have a look and let me know what you think?

Cheers,

Tom

@tomglynch
Copy link
Author

@lostintangent just a follow up comment to see if you have any interest in merging these changes? Cheers

@awalland
Copy link

awalland commented Mar 4, 2025

i would also love seeing this merged, since i have the same problem described in #90

@tomglynch
Copy link
Author

@lostintangent if no response soon I think I'll pop the fork up on the vs code extension store.

@lostintangent
Copy link
Owner

@tomglynch hey apologies! I'll review this tomorrow and we can get it merged this week

Copy link
Owner

@lostintangent lostintangent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! My comments below are essentially just thoughts on how to simplify the implementation, since I think we may be duplicating logic that we don't need. But I'm out of town and haven't been able to actually run/debug the code. So I'm just thinking out loud 👍

Additionally, since this extension has millions of installs, and this PR is making a notable UX change, we should add a setting to control whether to always show the status bar or not. And default it to false. That way the current behavior doesn't change, but you and others can opt into having the status bar always visible.

src/extension.ts Outdated
import * as minimatch from "minimatch";

// Helper function for file pattern matching
function matches(uri: vscode.Uri) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of duplicating this function, we should define it as a reusable utility that can be imported in this file and in the watcher.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just export the function from the watcher module and then reuse it here

src/extension.ts Outdated
}

// Initialize the store and context based on the configuration
const initialEnabled = vscode.workspace.getConfiguration('gitdoc').get('enabled', false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code was handling this logic already, since "config.enabled" pulls its value from the workspace configuration. Is there a reason we need to change it to this more verbose implementation?

src/extension.ts Outdated
// Initialize the store and context based on the configuration
const initialEnabled = vscode.workspace.getConfiguration('gitdoc').get('enabled', false);
store.enabled = initialEnabled;
updateContext(initialEnabled, false); // Set initial context to match config
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateContext will already be run in response to setting store.enabled, so we don't need this. And then related to my previous comment, I think we can just revert this entire hunk.

src/extension.ts Outdated
() => checkEnabled(git)
() => store.enabled,
(enabled) => {
updateContext(enabled, true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need this since checkEnabled will already update the context as needed.

src/extension.ts Outdated
(enabled) => {
updateContext(enabled, true);
checkEnabled(git);
debouncedUpdateStatusBar(vscode.window.activeTextEditor);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be handled by the checkEnabled function, and effectively revert to the previous code. That way this reaction is simply watching for enabled changes and then updating the UX based on that (via checkEnabled)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you already have a reaction in the watcher module that will update the status bar when the store.enabled changes. So I think we can just remove this?

@tomglynch
Copy link
Author

Thanks for all your comments @lostintangent! I agree with everything and have applied them to my latest commit.

  1. Added the gitdoc.alwaysShowStatusBarIcon setting (defaulting to false) as you suggested
  2. Moved the matches function to watcher.ts and made it exported for reuse
  3. Simplified the initialization code to use config.enabled directly
  4. Removed redundant context updates since checkEnabled handles this
  5. Removed the debounced handler as you suggested it was unnecessary
  6. Consolidated status bar updates into the checkEnabled function

The changes maintain backward compatibility while allowing users to opt into the new behavior. Let me know if you'd like me to make any additional adjustments.

I also added a few tests that I haven't pushed yet if you'd like to take a look - but perhaps that's a seperate PR.

@lgruen
Copy link

lgruen commented May 10, 2025

@lostintangent Thanks for your work on this! Any chance to get this PR merged? I think a couple of people are affected by #90.

@M-Kepler
Copy link

I'm having the same issue

@tomglynch
Copy link
Author

@lostintangent

@ascholerChemeketa
Copy link

Would love to see this merged. Currently resorting to a fork to use this in courses to avoid #90.

@owenarden
Copy link

I am also affected by this. +1 for merging :)

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.

9 participants