summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/template_selector.js.es6
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/blob/template_selector.js.es6')
-rw-r--r--app/assets/javascripts/blob/template_selector.js.es611
1 files changed, 9 insertions, 2 deletions
diff --git a/app/assets/javascripts/blob/template_selector.js.es6 b/app/assets/javascripts/blob/template_selector.js.es6
index ba60b3b2b98..4e309e480b0 100644
--- a/app/assets/javascripts/blob/template_selector.js.es6
+++ b/app/assets/javascripts/blob/template_selector.js.es6
@@ -68,8 +68,15 @@
// To be implemented on the extending class
// e.g.
// Api.gitignoreText item.name, @requestFileSuccess.bind(@)
- requestFileSuccess(file, skipFocus) {
- this.editor.setValue(file.content, 1);
+ requestFileSuccess(file, { skipFocus, append } = {}) {
+ const oldValue = this.editor.getValue();
+ let newValue = file.content;
+
+ if (append && oldValue.length && oldValue !== newValue) {
+ newValue = oldValue + '\n\n' + newValue;
+ }
+
+ this.editor.setValue(newValue, 1);
if (!skipFocus) this.editor.focus();
if (this.editor instanceof jQuery) {