Skip to content

Commit 2543f15

Browse files
committed
Remove parent path when typing a '..' path.
1 parent 8ddd550 commit 2543f15

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

web_src/js/features/repo-editor.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,20 @@ 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');
7880
if (parts.length > 1) {
7981
let containSpace = false;
8082
for (let i = 0; i < parts.length; ++i) {
8183
const value = parts[i];
84+
if (value.trim() === '..') {
85+
// remove previous tree path
86+
if (links.length > 0) {
87+
links[links.length - 1].remove();
88+
dividers[dividers.length - 1].remove();
89+
}
90+
continue;
91+
}
8292
if (i < parts.length - 1) {
8393
if (value.length) {
8494
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));

0 commit comments

Comments
 (0)