Private
Public Access
0
0
This commit is contained in:
2026-06-03 00:47:40 -04:00
parent 79a12d2c3e
commit 7a34edf605
6 changed files with 153 additions and 60 deletions
@@ -0,0 +1,5 @@
# Track markdown_helper_language_api_compat_20260603 Context
- [Specification](./spec.md)
- [Implementation Plan](./plan.md)
- [Metadata](./metadata.json)
@@ -0,0 +1,11 @@
{
"id": "markdown_helper_language_api_compat_20260603",
"title": "Fix markdown_helper.py for imgui-bundle >=1.92.801",
"phase": null,
"created": "2026-06-03",
"status": "in_progress",
"spec_file": "spec.md",
"plan_file": "plan.md",
"depends_on": ["clean_install_test_20260603"],
"completion_checkpoints": []
}
@@ -0,0 +1,24 @@
# Implementation Plan: Fix markdown_helper.py for imgui-bundle >=1.92.801
## Phase 1: Red - Confirm bug
- [x] Task 1.1: Run `tests/test_clean_install.py` in opt-in mode (RUN_CLEAN_INSTALL_TEST=1) - confirm AttributeError on TextEditor.LanguageDefinitionId
- [x] Task 1.2: Capture full traceback for git note
## Phase 2: Green - Apply version-compat shim
- [ ] Task 2.1: Add module-level `_get_language_id(name)` helper to markdown_helper.py
- [ ] Task 2.2: Add module-level `_set_editor_language(editor, lang_obj)` helper
- [ ] Task 2.3: Add module-level `_get_editor_language_name(editor)` helper
- [ ] Task 2.4: Replace `_lang_map` initialization to use `_get_language_id(...)`
- [ ] Task 2.5: Replace lines 128, 134, 135, 136 with shim calls
- [ ] Task 2.6: Handle the "none" fallback case (return None, skip set call)
- [ ] Task 2.7: Syntax check (ast.parse)
## Phase 3: Verify
- [ ] Task 3.1: Run `tests/test_clean_install.py` in opt-in mode - should pass (1 passed, clone+sync+launch+hook API)
- [ ] Task 3.2: Run local markdown-related tests (if any) to ensure no regression in 1.92.5 env
- [ ] Task 3.3: Import test for the new helpers (both APIs should work)
## Phase 4: Commit
- [ ] Task 4.1: Atomic commit with descriptive message
- [ ] Task 4.2: Git note with root cause analysis
- [ ] Task 4.3: Update tracks.md to register this fix track
@@ -0,0 +1,30 @@
# Fix markdown_helper.py for imgui-bundle >=1.92.801
## Bug
`src/markdown_helper.py` uses `ed.TextEditor.LanguageDefinitionId.<lang>` enum and `editor.set_language_definition(enum)` calls. These were removed in `imgui-bundle>=1.92.801`. Replacement: `ed.TextEditor.Language.<lang>()` factory functions and `editor.set_language(obj)` method.
The bug surfaces only on clean installs (where `uv sync` resolves the latest `imgui-bundle`). The local dev environment has 1.92.5 pinned, masking the issue. The `clean_install_test_20260603` opt-in test caught this on first run.
## Affected Code
- `src/markdown_helper.py:37-48``_lang_map` initialization with enum values
- `src/markdown_helper.py:128``ed.TextEditor.LanguageDefinitionId.none` fallback
- `src/markdown_helper.py:134``editor.set_language_definition(lang_id)` call
- `src/markdown_helper.py:135``editor.get_language_definition_name()` getter
- `src/markdown_helper.py:136``editor.set_language_definition(lang_id)` re-set
## Fix Strategy
Version-compat shim: detect which API is available at runtime and dispatch to the right one. This is safer than pinning `imgui-bundle` (avoids forcing the dev env to upgrade) and safer than hard-coding the new API (would break the 1.92.5 dev env).
The shim:
- Tries `TextEditor.Language.<name>()` first (1.92.801+)
- Falls back to `TextEditor.LanguageDefinitionId.<name>` (1.92.5)
- Returns `None` for "no language" (handled by not calling set_language)
- Provides `_set_editor_language(editor, lang_obj)` that dispatches to the right method
## Files Touched
- `src/markdown_helper.py` — add shim helpers, replace enum references
- (Optional) `pyproject.toml` — add `imgui-bundle>=1.92.5,<1.93` constraint to prevent future major version drift