Skip to content

Commit 8a458ed

Browse files
committed
only call join when backspace is pressed in keyup event and clean up
1 parent 3d30e8f commit 8a458ed

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

web_src/js/features/repo-editor.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,11 @@ export function initRepoEditor() {
107107

108108
const $editFilename = $('#file-name');
109109
$editFilename.on('input', function () {
110-
let value;
111110
const parts = $(this).val().split('/');
112111

113112
if (parts.length > 1) {
114113
for (let i = 0; i < parts.length; ++i) {
115-
value = parts[i];
114+
const value = parts[i];
116115
if (i < parts.length - 1) {
117116
if (value.length) {
118117
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(this));
@@ -130,18 +129,16 @@ export function initRepoEditor() {
130129

131130
$editFilename.on('keyup', function (e) {
132131
const $section = $('.breadcrumb span.section');
133-
const $divider = $('.breadcrumb div.divider');
134-
let value;
135132

136133
if (e.keyCode === 8 && getCursorPosition($(this)) === 0 && $section.length > 0) {
137-
value = $section.last().find('a').text();
134+
const $divider = $('.breadcrumb div.divider');
135+
const value = $section.last().find('a').text();
138136
$(this).val(value + $(this).val());
139137
$(this)[0].setSelectionRange(value.length, value.length);
140138
$section.last().remove();
141139
$divider.last().remove();
140+
joinTreePath($(this));
142141
}
143-
144-
joinTreePath($(this));
145142
});
146143

147144
const $editArea = $('.repository.editor textarea#edit_area');

0 commit comments

Comments
 (0)