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

Guard public selection api #797

Merged
merged 3 commits into from
Jul 14, 2017
Merged

Guard public selection api #797

merged 3 commits into from
Jul 14, 2017

Conversation

mofux
Copy link
Contributor

@mofux mofux commented Jul 14, 2017

Fixes #796 by soft-failing if selection manager is not yet available (term.open not yet called). I believe this is better than throwing an error. This behaviour lines up with the behaviour of the linkifier, that only throws for sensitive api calls (like registering a link matcher for example), but otherwise soft-fails too.

@coveralls
Copy link

coveralls commented Jul 14, 2017

Coverage Status

Coverage decreased (-0.03%) to 69.465% when pulling 0af4b17 on mofux:guard_selection_api into 7cfc2ff on sourcelair:master.

src/xterm.js Outdated
@@ -1437,29 +1437,33 @@ Terminal.prototype.deregisterLinkMatcher = function(matcherId) {
* Gets whether the terminal has an active selection.
*/
Terminal.prototype.hasSelection = function() {
return this.selectionManager.hasSelection;
return !!(this.selectionManager && this.selectionManager.hasSelection);
Copy link
Member

Choose a reason for hiding this comment

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

Let's simplify this so it's easier to read:

if (!this.selectionManager) {
  return false;
}
return this.selectionManager.hasSelection;

@Tyriar Tyriar added this to the 2.9.0 milestone Jul 14, 2017
@Tyriar Tyriar self-assigned this Jul 14, 2017
@coveralls
Copy link

coveralls commented Jul 14, 2017

Coverage Status

Coverage decreased (-0.07%) to 69.419% when pulling 6df6aad on mofux:guard_selection_api into 7cfc2ff on sourcelair:master.

@coveralls
Copy link

coveralls commented Jul 14, 2017

Coverage Status

Coverage decreased (-0.03%) to 69.445% when pulling e2b43a4 on mofux:guard_selection_api into 1fd087e on sourcelair:master.

@Tyriar Tyriar merged commit c94fdae into xtermjs:master Jul 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants