Skip to content

Commit

Permalink
Invisible else statements are added to _commonprefix function
Browse files Browse the repository at this point in the history
  • Loading branch information
knikolaevskii committed Jun 27, 2024
1 parent e490969 commit 3e6985f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/prompt_toolkit/completion/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ def get_suffix(completion: Completion) -> str:
"_commonprefix_1": False, # Branch for checking if not strings
"_commonprefix_2": False, # Branch for comparing characters
"_commonprefix_3": False, # Branch for when the characters do not match
"_commonprefix_3_else": False, # Branch for else case of when the characters match
}

def _commonprefix(strings: Iterable[str]) -> str:
Expand All @@ -445,7 +446,9 @@ def _commonprefix(strings: Iterable[str]) -> str:
if c != s2[i]:
branch_coverage["_commonprefix_3"] = True
print("Branch 3 was hit")
print("here")
return s1[:i]
else:
branch_coverage["_commonprefix_3_else"] = True
print("Branch 3 was not hit")

return s1

0 comments on commit 3e6985f

Please sign in to comment.