Skip to content

Commit

Permalink
Merge pull request #54 from massimocode/master
Browse files Browse the repository at this point in the history
Fix issue with input closing when losing focus
  • Loading branch information
shanalikhan authored Jul 30, 2016
2 parents 5574a1d + f941ae6 commit 70a4fed
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions src/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Commons {

var me = this;
var setting: Setting = new Setting();

return new Promise<Setting>(async (resolve, reject) => {

await fManager.FileManager.FileExists(me.en.APP_SETTINGS).then(async function (fileExist: boolean) {
Expand Down Expand Up @@ -82,40 +82,49 @@ export class Commons {
var me = this;
var opt = Commons.GetInputBox(true);
return new Promise<boolean>((resolve, reject) => {

vscode.window.showInputBox(opt).then(async (token) => {
token = token.trim();
if (token) {
sett.Token = token;
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Token Saved", 1000);
(function getToken() {
vscode.window.showInputBox(opt).then(async (token) => {
if (token && token.trim()) {
sett.Token = token.trim();
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Token Saved", 1000);
}
resolve(saved);
}, function (err: any) {
reject(err);
});
} else {
if (token !== 'esc') {
getToken()
}
resolve(saved);
}, function (err: any) {
reject(err);
});
}
});
}
});
} ());
});
}
public async GetGistAndSave(sett: Setting): Promise<boolean> {
var me = this;
var opt = Commons.GetInputBox(false);
return new Promise<boolean>((resolve, reject) => {
vscode.window.showInputBox(opt).then(async (gist) => {
gist = gist.trim();
if (gist) {
sett.Gist = gist;
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Gist Saved", 1000);
(function getGist() {
vscode.window.showInputBox(opt).then(async (gist) => {
if (gist && gist.trim()) {
sett.Gist = gist.trim();
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Gist Saved", 1000);
}
resolve(saved);
}, function (err: any) {
reject(err);
});
} else {
if (gist !== 'esc') {
getGist()
}
resolve(saved);
}, function (err: any) {
reject(err);
});
}
}
});
});

});
Expand All @@ -128,15 +137,15 @@ export class Commons {
let options: vscode.InputBoxOptions = {
placeHolder: "Enter Github Personal Access Token",
password: false,
prompt: "Link is opened to get the github token."
prompt: "Link is opened to get the github token. Enter token and press [Enter] or type 'esc' to cancel......................................................."
};
return options;
}
else {
let options: vscode.InputBoxOptions = {
placeHolder: "Enter GIST ID",
password: false,
prompt: "If you never upload the files in any machine before then upload it before."
prompt: "Enter GIST ID from previously uploaded settings and press [Enter] or type 'esc' to cancel................................................................."
};
return options;
}
Expand Down

0 comments on commit 70a4fed

Please sign in to comment.