-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(NewFileCommand): show folder selector
This change addresses a behaviour were the folder selector (quick pick) wans't show under all circumstances. Now, provided "typeahead.enabled" is set to be true, the folder selector will be shown if more than one director is present at the desired location.
- Loading branch information
Showing
7 changed files
with
219 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
import * as fs from 'fs'; | ||
import { sync as globSync } from 'glob'; | ||
import * as glob from 'glob'; | ||
import * as path from 'path'; | ||
import { workspace } from 'vscode'; | ||
import { Uri, workspace } from 'vscode'; | ||
import { getConfiguration } from '../lib/config'; | ||
|
||
export class TreeWalker { | ||
|
||
public async directories(sourcePath: string): Promise<string[]> { | ||
const ignore = this.configIgnoredGlobs() | ||
.map(this.invertGlob); | ||
|
||
const results = globSync('**', { cwd: sourcePath, ignore }) | ||
.filter((file) => fs.statSync(path.join(sourcePath, file)).isDirectory()) | ||
.map((file) => path.sep + file); | ||
|
||
return results; | ||
return glob | ||
.sync('**/', { cwd: sourcePath, ignore: this.configIgnore() }) | ||
.map((file) => path.sep + file.replace(/\/$/, '')); | ||
} | ||
|
||
private configIgnoredGlobs(): string[] { | ||
const configFilesExclude = { | ||
private configIgnore(): string[] { | ||
const excludedFilesConfig = { | ||
...getConfiguration('typeahead.exclude'), | ||
...workspace.getConfiguration('files.exclude', null) | ||
}; | ||
return Object.keys(configFilesExclude) | ||
.filter((key) => configFilesExclude[key] === true); | ||
} | ||
|
||
private invertGlob(pattern: string) { | ||
return pattern.replace(/^!/, ''); | ||
return Object | ||
.keys(excludedFilesConfig) | ||
.filter((key) => excludedFilesConfig[key] === true) | ||
.map(((pattern) => pattern.replace(/^!/, ''))); | ||
} | ||
} |
Oops, something went wrong.