Skip to content

v1.5.1: Code Suggestion Sanitisation & Automatic Indentation Alignment

Choose a tag to compare

@derailed-dash derailed-dash released this 04 Aug 20:40
· 23 commits to main since this release
aaf0094

馃殌 What's New in v1.5.1

This point release fixes inline code suggestion formatting issues by automatically sanitising line-number prefixes, stripping outer markdown block fences, and dynamically auto-aligning indentation levels across all code depth nesting.


鉁忥笍 Code Suggestion Sanitisation & Line-Number Prefix Stripping

  • Line-Number Prefix Filtering: Added sanitize_code_suggestion() to automatically strip line-number prefixes (e.g., 105 | , 105 + |, L105:) from inline code suggestions before posting to GitHub.
  • Strict Regex Matching: Differentiates pipe-delimited plain number prefixes (105 | ) from valid Python dictionary keys ({105: "foo"}) or switch labels (case 105:), preserving valid code structures.
  • Markdown Block Fence Clean-Up: Automatically strips outer markdown fences (``` or ```suggestion) if emitted by Gemini inside code_suggestion.

馃搻 Automatic Indentation Alignment across All Nesting Depths

  • Dynamic Target Indentation Matching: Added _auto_align_suggestion_indentation() to measure the exact leading indentation (spaces or tabs) of target source lines in the repository file.
  • Under-Indentation Delta Calculation: Automatically calculates indentation offsets ($$\text{delta} = \text{target_indent} - \text{first_s_indent}$$) and prepends proper leading whitespace to suggestions starting with 0 or partial indentation.
  • Supports All Indentation Depths: Correctly aligns suggestions across any nesting level (2, 4, 8, 12, 16+ spaces or tabs) while preserving relative multi-line block indentation.

馃搵 System Instruction & Schema Rules

  • Prompt Reinforcement: Updated suggestion_instruction in prompts.py to explicitly direct Gemini to avoid line numbers, line prefixes, or code block fences.
  • Schema Documentation: Updated InlineComment.code_suggestion description in schemas.py for stricter structural formatting guidance.

馃И Test Suite & Quality Assurance

  • Added unit tests for sanitize_code_suggestion and multi-level indentation alignment (test_auto_align_suggestion_indentation_deep_nesting, test_auto_align_suggestion_indentation_tabs).
  • 75 total unit tests passing cleanly.
  • Verified with codespell and ruff.