Skip to content

Commit 8dd689e

Browse files
committed
separate input and keyup events
1 parent ccf73c2 commit 8dd689e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

web_src/js/features/repo-editor.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,10 @@ export function initRepoEditor() {
9292
});
9393

9494
const $editFilename = $('#file-name');
95-
$editFilename.on('keyup input', function (e) {
96-
const $section = $('.breadcrumb span.section');
97-
const $divider = $('.breadcrumb div.divider');
95+
$editFilename.on('input', function (e) {
9896
let value;
9997
let parts;
10098

101-
if (e.keyCode === 8 && getCursorPosition($(this)) === 0 && $section.length > 0) {
102-
value = $section.last().find('a').text();
103-
$(this).val(value + $(this).val());
104-
$(this)[0].setSelectionRange(value.length, value.length);
105-
$section.last().remove();
106-
$divider.last().remove();
107-
}
10899
parts = $(this).val().split('/');
109100
if (parts.length > 1) {
110101
for (let i = 0; i < parts.length; ++i) {
@@ -133,6 +124,20 @@ export function initRepoEditor() {
133124
$('#tree_path').val(parts.join('/'));
134125
});
135126

127+
$editFilename.on('keyup', function (e) {
128+
const $section = $('.breadcrumb span.section');
129+
const $divider = $('.breadcrumb div.divider');
130+
let value;
131+
132+
if (e.keyCode === 8 && getCursorPosition($(this)) === 0 && $section.length > 0) {
133+
value = $section.last().find('a').text();
134+
$(this).val(value + $(this).val());
135+
$(this)[0].setSelectionRange(value.length, value.length);
136+
$section.last().remove();
137+
$divider.last().remove();
138+
}
139+
});
140+
136141
const $editArea = $('.repository.editor textarea#edit_area');
137142
if (!$editArea.length) return;
138143

0 commit comments

Comments
 (0)