Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for improving edit/history API in the editor. #291

Closed
MatthewBlanchard opened this issue May 22, 2022 · 3 comments
Closed

Suggestion for improving edit/history API in the editor. #291

MatthewBlanchard opened this issue May 22, 2022 · 3 comments
Labels
code-quality Doesn't improve user experience, only makes the code better. enhancement New feature or request proposal In planning phase

Comments

@MatthewBlanchard
Copy link
Contributor

let glyphModification = editor.beginModification()
glyphModification.inner.blah = foo // I'm a wrapper around a mutable reference to glyph!
editor.endModification(glyphModification)

Get rid of the extra scope created by the anonymous function that's currently used for glyph modifications, and instead just return a mutable reference to the glyph after calling begin mod and consume it in end mod.

This will help in a variety of ways:

Cleaner code, fewer indentations, less scopes.
No need to copy, clone, move data between the scopes.
More rusty.

There's also the potential of not having an endModification at all, and simply ending the edit when the token is dropped, but I don't think this is explicit enough. I'd argue that I'd rather have drop(glyphModification) panic at runtime unless editor.endModification() is called.

@ctrlcctrlv ctrlcctrlv added enhancement New feature or request proposal In planning phase code-quality Doesn't improve user experience, only makes the code better. labels Jul 19, 2022
@ctrlcctrlv
Copy link
Collaborator

@MatthewBlanchard Where'd we land on this?

@MatthewBlanchard
Copy link
Contributor Author

get_active_layer() now simply returns a normal old reference. You might have to wrap it in a block for borrowing reasons, but there's no longer closures involved.

@ctrlcctrlv
Copy link
Collaborator

Right, so this is done then I take it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality Doesn't improve user experience, only makes the code better. enhancement New feature or request proposal In planning phase
Projects
None yet
Development

No branches or pull requests

2 participants