From e320c08b2460f35a6b758e8bffc790e7ee3611f7 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 17 Oct 2017 21:15:27 -0500 Subject: [PATCH] Fix #4397 - Don't allow context menu when a line is empty --- src/components/Editor/GutterMenu.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/Editor/GutterMenu.js b/src/components/Editor/GutterMenu.js index 1d335d10a2..fa568b7e5b 100644 --- a/src/components/Editor/GutterMenu.js +++ b/src/components/Editor/GutterMenu.js @@ -5,6 +5,7 @@ import { connect } from "react-redux"; import { lineAtHeight } from "../../utils/editor"; import { getContextMenu, + getEmptyLines, getSelectedLocation, getSelectedSource, getVisibleBreakpoints, @@ -143,6 +144,10 @@ class GutterContextMenuComponent extends PureComponent { bp => bp.location.line === line ); + if (props.emptyLines.includes(line)) { + return; + } + gutterMenu({ event, sourceId, line, breakpoint, ...props }); } @@ -153,12 +158,16 @@ class GutterContextMenuComponent extends PureComponent { export default connect( state => { + const selectedSource = getSelectedSource(state); return { selectedLocation: getSelectedLocation(state), - selectedSource: getSelectedSource(state), + selectedSource: selectedSource, breakpoints: getVisibleBreakpoints(state), pauseData: getPause(state), - contextMenu: getContextMenu(state) + contextMenu: getContextMenu(state), + emptyLines: selectedSource + ? getEmptyLines(state, selectedSource.toJS()) + : [] }; }, dispatch => bindActionCreators(actions, dispatch)