Skip to content

Commit

Permalink
DevTools: Sources: Right clicking in a gutter always gets line number
Browse files Browse the repository at this point in the history
If you right clicked very precicsely in the gutter, you could hit a div
that was not a line number. Then target.textContent would be " ", and
the line number would be NaN.

This patch uses a more robust method to find the line number div.

BUG=none

Review-Url: https://codereview.chromium.org/2545623002
Cr-Commit-Position: refs/heads/master@{#436768}
  • Loading branch information
JoelEinbinder authored and Commit bot committed Dec 6, 2016
1 parent 2cf28d6 commit 0f8327a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion front_end/source_frame/SourcesTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
_contextMenu(event) {
var contextMenu = new UI.ContextMenu(event);
event.consume(true); // Consume event now to prevent document from handling the async menu
var target = event.target.enclosingNodeOrSelfWithClass('CodeMirror-gutter-elt');
var wrapper = event.target.enclosingNodeOrSelfWithClass('CodeMirror-gutter-wrapper');
var target = wrapper ? wrapper.querySelector('.CodeMirror-linenumber') : null;
var promise;
if (target) {
promise = this._delegate.populateLineGutterContextMenu(contextMenu, parseInt(target.textContent, 10) - 1);
Expand Down

0 comments on commit 0f8327a

Please sign in to comment.