Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gitignore decorations when .git/info/exclude file is edited #106270

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions extensions/git/src/decorationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { window, workspace, Uri, Disposable, Event, EventEmitter, Decoration, DecorationProvider, ThemeColor } from 'vscode';
import { window, workspace, Uri, Disposable, Event, EventEmitter, Decoration, DecorationProvider, ThemeColor, TextDocument } from 'vscode';
import * as path from 'path';
import { Repository, GitResourceGroup } from './repository';
import { Model } from './model';
Expand All @@ -21,7 +21,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {

constructor(private model: Model) {
this.onDidChangeDecorations = fireEvent(anyEvent<any>(
filterEvent(workspace.onDidSaveTextDocument, e => e.fileName.endsWith('.gitignore')),
filterEvent(workspace.onDidSaveTextDocument, this.isIgnoreConfig),
model.onDidOpenRepository,
model.onDidCloseRepository
));
Expand Down Expand Up @@ -78,6 +78,13 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
}
}

private isIgnoreConfig(document: TextDocument): boolean {
return (
document.fileName.endsWith('.gitignore') ||
document.fileName.replace(/\\/g, '/').endsWith('.git/info/exclude')
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure fileName includes the full path and is not just the file name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's a shorthand for uri.fsPath.

);
}

dispose(): void {
this.disposables.forEach(d => d.dispose());
this.queue.clear();
Expand Down