Skip to content

Commit 3d19281

Browse files
committed
Fix processing of .. when using paste.
1 parent 6071df1 commit 3d19281

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

web_src/js/features/repo-editor.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export function initRepoEditor() {
7575
}
7676
filenameInput.addEventListener('input', function () {
7777
const parts = filenameInput.value.split('/');
78-
const links = document.querySelectorAll('.breadcrumb span.section');
79-
const dividers = document.querySelectorAll('.breadcrumb-divider');
78+
const links = Array.from(document.querySelectorAll('.breadcrumb span.section'));
79+
const dividers = Array.from(document.querySelectorAll('.breadcrumb .breadcrumb-divider'));
8080
if (parts.length > 1) {
8181
let containSpace = false;
8282
for (let i = 0; i < parts.length; ++i) {
@@ -85,15 +85,21 @@ export function initRepoEditor() {
8585
if (trimValue === '..') {
8686
// remove previous tree path
8787
if (links.length > 0) {
88-
links[links.length - 1].remove();
89-
dividers[dividers.length - 1].remove();
88+
const link = links.pop();
89+
const divider = dividers.pop();
90+
link.remove();
91+
divider.remove();
9092
}
9193
continue;
9294
}
9395
if (i < parts.length - 1) {
9496
if (trimValue.length) {
95-
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));
96-
$('<div class="breadcrumb-divider">/</div>').insertBefore($(filenameInput));
97+
const $link = $(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`);
98+
const $divider = $('<div class="breadcrumb-divider">/</div>');
99+
links.push($link.get(0));
100+
dividers.push($divider.get(0));
101+
$link.insertBefore($(filenameInput));
102+
$divider.insertBefore($(filenameInput));
97103
}
98104
} else {
99105
filenameInput.value = value;

0 commit comments

Comments
 (0)