mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
fixes #29728
This commit is contained in:
@@ -982,14 +982,25 @@ export class CommandCenter {
|
||||
|
||||
@command('git.ignore')
|
||||
async ignore(...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
const resources = resourceStates
|
||||
.filter(s => s instanceof Resource) as Resource[];
|
||||
if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
|
||||
const uri = window.activeTextEditor && window.activeTextEditor.document.uri;
|
||||
|
||||
if (!resources.length) {
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
return await this.model.ignore([uri]);
|
||||
}
|
||||
|
||||
const uris = resourceStates
|
||||
.filter(s => s instanceof Resource)
|
||||
.map(r => r.resourceUri);
|
||||
|
||||
if (!uris.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.model.ignore(resources);
|
||||
await this.model.ignore(uris);
|
||||
}
|
||||
|
||||
private createCommand(id: string, key: string, method: Function, skipModelCheck: boolean): (...args: any[]) => any {
|
||||
|
||||
@@ -536,11 +536,11 @@ export class Model implements Disposable {
|
||||
return await this.run(Operation.GetCommitTemplate, async () => this.repository.getCommitTemplate());
|
||||
}
|
||||
|
||||
async ignore(files: Resource[]): Promise<void> {
|
||||
async ignore(files: Uri[]): Promise<void> {
|
||||
return await this.run(Operation.Ignore, async () => {
|
||||
const ignoreFile = `${this.repository.root}${path.sep}.gitignore`;
|
||||
const textToAppend = files
|
||||
.map(file => path.relative(this.repository.root, file.resourceUri.fsPath).replace(/\\/g, '/'))
|
||||
.map(uri => path.relative(this.repository.root, uri.fsPath).replace(/\\/g, '/'))
|
||||
.join('\n');
|
||||
|
||||
const document = await new Promise(c => fs.exists(ignoreFile, c))
|
||||
|
||||
Reference in New Issue
Block a user