Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion: always insert longest match #1184

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Completion: always insert longest match
Previously, longest common match completion would only apply if there
was a word before the cursor.

Suggested in #1090
  • Loading branch information
p-ouellette committed Mar 31, 2023
commit 5cc7fe3c38e0c5b5f34e46f4c85db6b2b04b0fe8
12 changes: 6 additions & 6 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,14 @@ func matchFile(s string) (matches []string, longest []rune) {
}
matches = append(matches, item)

if longest != nil {
longest = matchLongest(longest, []rune(name))
} else if s != "" {
if longest == nil {
if f.Mode().IsRegular() {
longest = []rune(name + " ")
} else {
longest = []rune(name + escape(string(filepath.Separator)))
}
} else {
longest = matchLongest(longest, []rune(name))
}
}

Expand Down Expand Up @@ -437,10 +437,10 @@ func completeFile(acc []rune) (matches []string, longestAcc []rune) {

matches = append(matches, f.Name())

if longestAcc != nil {
longestAcc = matchLongest(longestAcc, []rune(f.Name()))
} else if s != "" {
if longestAcc == nil {
longestAcc = []rune(f.Name())
} else {
longestAcc = matchLongest(longestAcc, []rune(f.Name()))
}
}

Expand Down