ChimeHQ / Chime

An editor for macOS
https://www.chimehq.com
BSD 3-Clause "New" or "Revised" License
309 stars 14 forks source link

Small bug in Document/Models/Project.swift #2

Closed wjk closed 11 months ago

wjk commented 11 months ago

While reading through your code I noticed the following:

https://github.com/ChimeHQ/Chime/blob/72e6297f6971a2dd235701016390267584fe60e5/Edit/Modules/Document/Models/Project.swift#L72-L73

If Chime is built in release, the call to textDocuments.remove will be elided, as it is only used in the context of the assert call, and those are removed when doing a release build. As a result, you wouldn’t be able to successfully remove documents from projects. You would need to do this to make it work:

case let doc as TextDocument:
    let removed: Bool = textDocuments.remove(doc) != nil
    assert(removed)
mattmassicotte commented 11 months ago

Oh boy, that isn't the first time I've made a mistake like that. Thank you so much!

mattmassicotte commented 11 months ago

Fixed with 0a00ba614e7ff04c75ba4a8b890fc2200494b213