Skip to content

Commit a1eda58

Browse files
committed
Handle overwrite message
1 parent 7053e6d commit a1eda58

File tree

1 file changed

+2
-31
lines changed

1 file changed

+2
-31
lines changed

src/CodeSnippetInputDialog.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ export function showInputDialog(
107107
return null;
108108
}
109109

110-
console.log(idx);
111-
112110
if (validateForm(result) === false) {
113111
showInputDialog(
114112
codeSnippetWidget,
@@ -119,10 +117,6 @@ export function showInputDialog(
119117
body
120118
);
121119
} else {
122-
// if (idx === -1) {
123-
// idx = codeSnippetWidget.codeSnippetWidgetModel.snippets.length;
124-
// }
125-
126120
const tags = result.value.slice(3);
127121
const newSnippet: ICodeSnippet = {
128122
name: result.value[0].replace(' ', ''),
@@ -165,32 +159,10 @@ function createNewSnippet(
165159
}
166160
});
167161

168-
console.log('add');
169-
console.log(codeSnippetManager.snippets);
170-
// const request = contentsService.save(
171-
// 'snippets/' + newSnippet.name + '.json',
172-
// {
173-
// type: 'file',
174-
// format: 'text',
175-
// content: JSON.stringify(newSnippet)
176-
// }
177-
// );
178-
179162
codeSnippetWidget.renderCodeSnippetsSignal.emit(codeSnippetManager.snippets);
180163
showMessage({
181164
body: new MessageHandler(),
182165
});
183-
// request.then(_ => {
184-
// // add the new snippet to the snippet model
185-
// // codeSnippet.codeSnippetWidgetModel.addSnippet(newSnippet, newSnippet.id);
186-
// // codeSnippet.codeSnippetWidgetModel.updateSnippetContents();
187-
// // const newSnippets = codeSnippet.codeSnippetWidgetModel.snippets;
188-
// // codeSnippet.codeSnippets = newSnippets;
189-
// // codeSnippet.renderCodeSnippetsSignal.emit(newSnippets);
190-
// // showMessage({
191-
// // body: new MessageHandler()
192-
// // });
193-
// });
194166
}
195167

196168
/**
@@ -203,7 +175,7 @@ export async function saveOverWriteFile(
203175
): Promise<boolean> {
204176
const newName = newSnippet.name;
205177

206-
await shouldOverwrite(newName).then((res) => {
178+
return await shouldOverwrite(newName).then((res) => {
207179
if (res) {
208180
newSnippet.id = oldSnippet.id;
209181

@@ -222,7 +194,6 @@ export async function saveOverWriteFile(
222194
return true;
223195
}
224196
});
225-
return false;
226197
}
227198

228199
/**
@@ -235,7 +206,7 @@ async function shouldOverwrite(newName: string): Promise<boolean> {
235206
buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Overwrite' })],
236207
};
237208
return showDialog(options).then((result) => {
238-
return Promise.resolve(result.button.accept);
209+
return result.button.accept;
239210
});
240211
}
241212

0 commit comments

Comments
 (0)