Skip to content

Fix autocompletion#96

Merged
bellini666 merged 6 commits intobellini666:masterfrom
benediktziegler:fix-autocompletion
Feb 28, 2026
Merged

Fix autocompletion#96
bellini666 merged 6 commits intobellini666:masterfrom
benediktziegler:fix-autocompletion

Conversation

@benediktziegler
Copy link
Copy Markdown
Contributor

This pull request updates the language server's completion trigger behavior to improve the developer experience. The main change is the expansion of the set of characters that will trigger code completion suggestions.

Enhancements to code completion triggers:

  • Expanded the trigger_characters in the language server's CompletionOptions to include "(" and "," in addition to ", so that code completion is now triggered when the user types a quote, parenthesis, or comma.
  • Don't suggest the fixture name which is currently edited.
  • Special handle the "," and add a space as prefix on insertion.

- Provide completions for incomplete test/fixture signatures using
  text-based
  heuristics when AST parsing fails (e.g. open paren, missing
  colon/body)
- Support multiline, trailing newline, and signatures without parens
- Handle usefixtures/pytestmark decorators with open paren
- Add extensive tests for all fallback scenarios
- Expand completion trigger characters to include ( and ,
Prevents a fixture from being suggested as a parameter to itself in
completion
lists. Updates filtering logic and tests to handle current fixture
context.
When completion is triggered by a comma, insert a space before the
fixture name so that "fixture1," becomes "fixture1, fixture2". Update
completion helpers and tests to support insert prefix.
- Scan decorator lines individually for scope= to avoid quadratic string
  ops
- Refactor completion filtering to use CompletionOpts struct for clarity
- Improve edge case handling in completion context detection
- Clarify scan limits and fallback behavior in resolver comments
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 90.45455% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.17%. Comparing base (230c02e) to head (43a4455).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/fixtures/resolver.rs 95.00% 10 Missing ⚠️
src/providers/completion.rs 56.25% 7 Missing ⚠️
src/main.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
+ Coverage   61.25%   63.17%   +1.92%     
==========================================
  Files          26       26              
  Lines        3198     3392     +194     
==========================================
+ Hits         1959     2143     +184     
- Misses       1239     1249      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves pytest-language-server completion UX by expanding completion trigger characters, refining fixture suggestions (e.g., exclude the currently edited fixture), and adding a text-based completion-context fallback for syntactically incomplete Python.

Changes:

  • Expanded LSP completion trigger characters to include ( and , in addition to " and added comma-trigger insertion spacing.
  • Added per-request completion options to exclude the current fixture from suggestions and to apply an insert-text prefix.
  • Implemented AST-based signature end detection plus a text-based fallback for incomplete/invalid Python, with extensive new tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/main.rs Expands CompletionOptions.trigger_characters to trigger completion on " / ( / ,.
src/providers/completion.rs Adds CompletionOpts to control scope filtering, self-exclusion, and comma-trigger spacing; updates completion builders and tests.
src/fixtures/resolver.rs Adds AST-based signature-end detection and a text fallback for completion context when parsing fails.
tests/test_fixtures.rs Adds many new tests covering signature/body context detection and text fallback scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bellini666
Copy link
Copy Markdown
Owner

@benediktziegler can you check copilot's reviews comments?

@benediktziegler
Copy link
Copy Markdown
Contributor Author

Fixed the comments.

Copy link
Copy Markdown
Owner

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bellini666 bellini666 merged commit 09f676c into bellini666:master Feb 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants