Skip to content

Commit ccf7650

Browse files
author
Jakob Werner
committed
Fixed glob not resuming
1 parent 24a5af3 commit ccf7650

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/extension.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ class RelativePath {
3232
private _workspacePath: string;
3333
private _configuration: any;
3434
private _pausedSearch: boolean;
35+
private _myGlob: any;
3536

3637
constructor() {
3738
this._items = null;
38-
this._pausedSearch = false;
39+
this._pausedSearch = null;
40+
this._myGlob = null;
3941
this._workspacePath = workspace.rootPath.replace(/\\/g, "/");
4042
this._configuration = workspace.getConfiguration("relativePath");
4143

@@ -66,33 +68,36 @@ class RelativePath {
6668
// Go through workspace to cache files
6769
private searchWorkspace() {
6870
let emptyItem: QuickPickItem = { label: "", description: "No files found" };
69-
let myGlob = null;
7071

7172
// Show loading info box
7273
let info = window.showQuickPick([emptyItem], { matchOnDescription: false, placeHolder: "Finding files... Please wait. (Press escape to cancel)" });
7374
info.then(
7475
(value?: any) => {
75-
if (myGlob) {
76-
myGlob.pause();
76+
if (this._myGlob) {
77+
this._myGlob.pause();
78+
}
79+
if (this._pausedSearch === null) {
80+
this._pausedSearch = true;
7781
}
78-
this._pausedSearch = true;
7982
},
8083
(rejected?: any) => {
81-
if (myGlob) {
82-
myGlob.pause();
84+
if (this._myGlob) {
85+
this._myGlob.pause();
86+
}
87+
if (this._pausedSearch === null) {
88+
this._pausedSearch = true;
8389
}
84-
this._pausedSearch = true;
8590
}
8691
);
8792

8893
// Search for files
8994
if (this._pausedSearch) {
9095
this._pausedSearch = false;
91-
if (myGlob) {
92-
myGlob.resume();
96+
if (this._myGlob) {
97+
this._myGlob.resume();
9398
}
9499
} else {
95-
myGlob = new Glob(this._workspacePath + "/**/*.*",
100+
this._myGlob = new Glob(this._workspacePath + "/**/*.*",
96101
{ ignore: this._configuration.get("ignore") },
97102
(err, files) => {
98103
if (err) {
@@ -102,7 +107,7 @@ class RelativePath {
102107
this._items = files;
103108
this.findRelativePath();
104109
});
105-
myGlob.on("end", () => {
110+
this._myGlob.on("end", () => {
106111
this._pausedSearch = false;
107112
});
108113
}

0 commit comments

Comments
 (0)