Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Multiple ColorEditor fixes #10401

Merged
merged 4 commits into from
Jan 22, 2015
Merged

Conversation

@redmunds redmunds self-assigned this Jan 21, 2015

start = this._startBookmark.find();
pos = this._marker.find();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this problem existed before with _startBookmark/_endBookmark, but _marker can be undefined or null, so that should be checked here to prevent a NPE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it can ever be null - cm.markText() always returns a TextMarker instance, and we initialize it in the constructor and only .clear() it on close, so when could this ever be null?
Of course, this._marker.find() can be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this - as long as the InlineColorEditor is open, this._marker is always an instance of TextMarker.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm certain that this._marker will never be null in the current code. But the constructor does not enforce that a valid marker is passed in and you can see some unit tests where creating new InlineColorEditor() does not pass any parameters (i.e. marker is undefined). This is just to be safe for any future usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, now that makes sense. Changed.

@redmunds
Copy link
Contributor

Done with review.

@redmunds
Copy link
Contributor

Looks good. Merging.

redmunds added a commit that referenced this pull request Jan 22, 2015
@redmunds redmunds merged commit c321002 into adobe:master Jan 22, 2015
@marcelgerber marcelgerber deleted the color-editor-fixes branch January 23, 2015 05:35
this._endBookmark.clear();
this._endBookmark = this.hostEditor._codeMirror.setBookmark(end);
this._marker.clear();
this._marker = this.hostEditor._codeMirror.markText(start, end);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelgerber Would you be interested in making a similar cleanup to the easing function editor at some point? Bonus points for finding a way to share some bookmark-management code between the two :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that and found that there's a lot of shared code in getCurrentRange - where to put shared utility functions for Inline Editor Extensions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants