Repository navigation
fix: fix/prevent-class-name-clashing - #7
Conversation
| final ComponentRepository _componentRepository; | ||
| final ProjectRepository _projectRepository; | ||
|
|
||
| Future<void> _onStarted( |
There was a problem hiding this comment.
Until this handler emits, takenClassNames is empty, so a child added or renamed in that window skips the check. Nothing re-checks it after the names load or on save. Re-validate the whole tree against takenClassNames after loading, or check again in the save handler before writing the code, so this window and existing clashes get caught.
| final taken = await _loadTakenClassNames(); | ||
| saved = saved.copyWith(takenClassNames: taken); | ||
| if (component.generatedClassNames.any(taken.contains)) { | ||
| emit(saved.copyWith(status: ComponentEditorStatus.classConflict)); |
There was a problem hiding this comment.
After a classConflict save, hasChanges is false. If the clash is fixed by renaming the other component, Cmd/Ctrl+S here hits the !state.hasChanges early return, and the code is never generated until the user makes a dummy edit. Let saves go through while status == classConflict, or don't count the save as done for code generation.
| ComponentEditorStatus.classConflict => | ||
| 'Saved, but the code was not generated: other components also ' | ||
| 'generate ${state.conflictingClassNames.join(', ')}. ' | ||
| 'Rename the clashing children', |
There was a problem hiding this comment.
If the root class is one of conflictingClassNames (for example, AB and a_b both created before this check existed), renaming children won't fix it, and the root can't be renamed here. When the root clashes, tell the user to rename or delete the other component instead.
Description
Type of Change