Fixes issues with create/copy/rename/delete

This commit is contained in:
Eric Amodio
2020-06-29 17:51:36 -04:00
parent 6a6876b023
commit 8bcf177236
3 changed files with 34 additions and 15 deletions

View File

@@ -5,7 +5,7 @@
'use strict';
import { commands, Event, EventEmitter, FileStat, FileType, Memento, TextDocumentShowOptions, Uri, ViewColumn } from 'vscode';
import { getRootUri, getRelativePath } from './extension';
import { getRootUri, getRelativePath, isChild } from './extension';
import { sha1 } from './sha1';
const textDecoder = new TextDecoder();
@@ -191,21 +191,29 @@ export class ChangeStore implements IChangeStore, IWritableChangeStore {
return entries;
}
const folderPath = getRelativePath(rootUri, uri);
const operations = this.getChanges(rootUri);
for (const operation of operations) {
switch (operation.type) {
case 'changed':
continue;
case 'created': {
const file = getRelativePath(rootUri, operation.uri);
entries.push([file, FileType.File]);
const filePath = getRelativePath(rootUri, operation.uri);
if (isChild(folderPath, filePath)) {
entries.push([filePath, FileType.File]);
}
break;
}
case 'deleted': {
const file = getRelativePath(rootUri, operation.uri);
const index = entries.findIndex(([path]) => path === file);
if (index !== -1) {
entries.splice(index, 1);
const filePath = getRelativePath(rootUri, operation.uri);
if (isChild(folderPath, filePath)) {
const index = entries.findIndex(([path]) => path === filePath);
if (index !== -1) {
entries.splice(index, 1);
}
}
break;
}