Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit 6cc979f

Browse files
committed
fix: more code cleanup
1 parent 4993714 commit 6cc979f

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/file-system/FileTree.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ function checkChildren(directory: string, expected: string[]) {
4747
})
4848
}
4949
describe('FileTree', () => {
50-
it('binarySearchStart', () => {
51-
const end = tree.binarySearchDirectoryStart('src/browse/')
52-
console.log(`end=${end} file=${tree.files[end]}`)
53-
})
54-
it('binarySearchEnd', () => {
55-
const end = tree.binarySearchDirectoryEnd('src/browse/', 0)
56-
console.log(`end=${end} file=${tree.files[end]}`)
57-
})
5850
checkChildren('src', ['src/browse/', 'src/git/', 'src/config.ts', 'src/extension.ts', 'src/log.ts'])
5951
checkChildren('', [
6052
'.github/workflows/',

src/file-system/FileTree.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class FileTree {
6666
return [...directDirectories, ...directFiles]
6767
}
6868

69-
public binarySearchDirectoryStart(directory: string): number {
69+
private binarySearchDirectoryStart(directory: string): number {
7070
if (directory === '') {
7171
return 0
7272
}
@@ -76,7 +76,7 @@ export class FileTree {
7676
)
7777
}
7878

79-
public binarySearchDirectoryEnd(directory: string, low: number): number {
79+
private binarySearchDirectoryEnd(directory: string, low: number): number {
8080
while (low < this.files.length && this.files[low].localeCompare(directory) <= 0) {
8181
low++
8282
}
@@ -86,7 +86,7 @@ export class FileTree {
8686
)
8787
}
8888

89-
public binarySearch({ low, high }: SearchRange, isGreater: (midpoint: number) => boolean): number {
89+
private binarySearch({ low, high }: SearchRange, isGreater: (midpoint: number) => boolean): number {
9090
while (low < high) {
9191
const midpoint = Math.floor(low + (high - low) / 2)
9292
if (isGreater(midpoint)) {

src/file-system/SourcegraphTreeDataProvider.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ export class SourcegraphTreeDataProvider implements vscode.TreeDataProvider<stri
4343
}
4444

4545
public async getParent(uriString?: string): Promise<string | undefined> {
46+
// Implementation note: this method is not implemented as
47+
// `SourcegraphUri.parse(uri).parentUri()` because that would return
48+
// URIs to directories that don't exist because they have no siblings
49+
// and are therefore automatically merged with their parent. For example,
50+
// imagine the following folder structure:
51+
// .gitignore
52+
// .github/workflows/ci.yml
53+
// src/command.ts
54+
// src/browse.ts
55+
// The parent of `.github/workflows/ci.yml` is `.github/` because the `workflows/`
56+
// directory has no sibling.
4657
if (!uriString) {
4758
return undefined
4859
}

0 commit comments

Comments
 (0)