Skip to content

Commit

Permalink
Remove parent path when typing a '..' path.
Browse files Browse the repository at this point in the history
  • Loading branch information
charles7668 committed Jun 29, 2024
1 parent 8ddd550 commit 2543f15
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions web_src/js/features/repo-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,20 @@ export function initRepoEditor() {
}
filenameInput.addEventListener('input', function () {
const parts = filenameInput.value.split('/');
const links = document.querySelectorAll('.breadcrumb span.section');
const dividers = document.querySelectorAll('.breadcrumb-divider');
if (parts.length > 1) {
let containSpace = false;
for (let i = 0; i < parts.length; ++i) {
const value = parts[i];
if (value.trim() === '..') {
// remove previous tree path
if (links.length > 0) {
links[links.length - 1].remove();
dividers[dividers.length - 1].remove();
}
continue;
}
if (i < parts.length - 1) {
if (value.length) {
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));
Expand Down

0 comments on commit 2543f15

Please sign in to comment.