Skip to content

Commit c643ba8

Browse files
committed
docs: document regex group precedence fix (Session 4)
1 parent 91acb13 commit c643ba8

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

CLAUDE_TODO.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,60 @@ Added comprehensive documentation to `/src/test/imports/import-manager.test.ts`:
11921192
- Create GitHub release with .vsix attached
11931193
- Update marketplace page with screenshots
11941194

1195+
### ✅ Additional Compatibility Improvements (Same Session)
1196+
1197+
**SECOND CRITICAL BUG DISCOVERED - Regex Group Precedence:**
1198+
1199+
User requested: "Check ALL old tests again, port everything relevant"
1200+
1201+
**Analysis Results:**
1202+
- Found 7 old test files total
1203+
- Previously ported: 6 files ✅
1204+
- **MISSED**: `utility-functions.test.ts`
1205+
1206+
**Critical Bug Found in Utilities:**
1207+
- **Problem**: Regex import groups didn't have matching precedence
1208+
- **Example**: Config `["Modules", "/angular/"]``/angular/` never matched!
1209+
- `Modules` keyword group captured all node_modules first
1210+
- Regex group never got a chance to match
1211+
- **Root Cause**: `importGroupSortForPrecedence` function was missing
1212+
- **Original Code**: Old extension sorted groups: regex first, then keywords
1213+
- **Our Code**: Processed groups in config order (WRONG!)
1214+
1215+
**Solution Implemented:**
1216+
1. Added `importGroupSortForPrecedence()` to `import-utilities.ts`
1217+
- Splits groups: regex groups first, keyword groups second
1218+
- Preserves original order within each category
1219+
2. Updated `ImportManager.organizeImports()`:
1220+
- Uses `importGroupSortForPrecedence(importGroups)` before processing
1221+
- Now matches original behavior exactly
1222+
1223+
**New Tests - Import Utilities (12 tests):**
1224+
- `importGroupSortForPrecedence` (4 tests):
1225+
- Prioritize regex groups, preserve order
1226+
- Handle lists with no regex groups
1227+
- Handle lists with only regex groups
1228+
- Handle empty lists
1229+
- `importSortByFirstSpecifier` (8 tests):
1230+
- Sort by specifier/alias/namespace
1231+
- String imports by basename
1232+
- Fallback to library name
1233+
- Case-insensitive locale-aware sorting
1234+
- Ascending/descending order
1235+
1236+
**Files Modified:**
1237+
- `src/imports/import-utilities.ts` - Added `importGroupSortForPrecedence()`
1238+
- `src/imports/import-manager.ts` - Use precedence sorting
1239+
- `src/test/imports/import-utilities.test.ts` - Created with 12 tests
1240+
1241+
**Test Coverage:**
1242+
- Previous: 54 tests
1243+
- Current: 66 tests (all passing ✅)
1244+
1245+
**Commits:**
1246+
- `91acb13` - fix: ensure regex import groups have matching precedence
1247+
11951248
---
11961249

11971250
**Last Updated**: 2025-10-03
1198-
**Status**: Phase 9 Complete ✅ | 54 tests passing | Full compatibility achieved 🎉
1251+
**Status**: Phase 9 Complete ✅ | 66 tests passing | Full compatibility achieved 🎉

0 commit comments

Comments
 (0)