Skip to content

Commit de66cd6

Browse files
committed
fix: tab completion cursor positioning and code formatting
Fix tab completion cursor bug where the cursor would jump to incorrect position after autocompleting filenames or paths. The cursor now correctly moves to the end of the completed text. Changes: - Fix cursor position after tab completion in index.html When tab completion updates the command line ($current), also update $cursorPos to match the new length. This prevents cursor quirks and incorrect positioning when typing after completion. - Fix code formatting in main.go Correct indentation inconsistency in autocomplete handler (lines 2815-2816) from spaces to tabs to match project style. Fixes reported issue where: - Tab completion caused cursor to appear in wrong position - Subsequent typing would insert characters at incorrect location
1 parent 8c0e82c commit de66cd6

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,11 @@
885885
886886
if (lcp && lcp !== basePart) {
887887
$current = cmd + ' ' + flagsPart + (dirPart + lcp);
888+
$cursorPos = $current.length; // Fix cursor position
888889
} else if (items.length === 1) {
889890
const one = items[0];
890891
$current = cmd + ' ' + flagsPart + (dirPart + one.name + (one.dir ? '/' : ''));
892+
$cursorPos = $current.length; // Fix cursor position
891893
} else {
892894
const list = items.map(it => it.name + (it.dir ? '/' : '')).join(' ');
893895
$buffer += `<div class='line out'>${makeClickable(ansiToHtml(list))}</div>`;

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,8 +2812,8 @@ func (s *server) handleComplete(w http.ResponseWriter, r *http.Request) {
28122812
}
28132813
if req.TextOnly {
28142814
// Use file category to check if viewable (text or image)
2815-
cat := getFileCategory(name)
2816-
if !(cat == FileCategoryText || cat == FileCategoryImage) {
2815+
cat := getFileCategory(name)
2816+
if !(cat == FileCategoryText || cat == FileCategoryImage) {
28172817
continue
28182818
}
28192819
}

0 commit comments

Comments
 (0)