Skip to content

Commit

Permalink
Fix issue that dbg! function name can't show in acm completion menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Oct 13, 2024
1 parent 5fa2ef5 commit d61c97e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions core/handler/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,21 @@ def get_display_label(self, item, display_new_text):
# Optimizing for Rust
try:
if (self.method_server_name == "rust-analyzer") and ("(\u2026)" in label or "()" in label): # '\u2026' is the unicode char: '…'
# When finding an ellipsis in 'label'
# replace 'fn' with function name in 'label'
function_name = label.split('(')[0]
detail_label = re.sub(r'\bfn\b', function_name, detail)

# Remove `pub` or `pub const` before function name.
match = re.search(r'\b(\w+\s*\([^)]*\)\s*->\s*\w+)\b', detail_label)
if match:
# If a match is successful, pick up the captured group
detail_label = match.group(1)
match_fn = re.search(r'\bfn\b', function_name)
if match_fn:
# When finding an ellipsis in 'label'
# replace 'fn' with function name in 'label'
detail_label = re.sub(r'\bfn\b', function_name, detail)

# Remove `pub` or `pub const` before function name.
match = re.search(r'\b(\w+\s*\([^)]*\)\s*->\s*\w+)\b', detail_label)
if match:
# If a match is successful, pick up the captured group
detail_label = match.group(1)
else:
detail_label = function_name
except:
pass

Expand Down

0 comments on commit d61c97e

Please sign in to comment.