Skip to content

Commit

Permalink
flash function when it is copied - feature firefox-devtools#4022
Browse files Browse the repository at this point in the history
  • Loading branch information
borian committed Nov 8, 2017
1 parent d45409f commit b40bb79
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/components/Editor/EditorMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getSourceLocationFromMouseEvent } from "../../utils/editor";
import { bindActionCreators } from "redux";
import { connect } from "react-redux";
import { findFunctionText } from "../../utils/function";
import { findClosestScope } from "../../utils/breakpoint/astBreakpointLocation";
import {
getContextMenu,
getSelectedLocation,
Expand All @@ -18,6 +19,7 @@ import {
} from "../../selectors";

import actions from "../../actions";

type Props = {
setContextMenu: Function
};
Expand All @@ -33,7 +35,9 @@ function getMenuItems(
jumpToMappedLocation,
toggleBlackBox,
addExpression,
getFunctionText
getFunctionText,
getFunctionLocation,
highlightLineRange
}
) {
const copySourceLabel = L10N.getStr("copySource");
Expand Down Expand Up @@ -121,7 +125,15 @@ function getMenuItems(
label: copyFunctionLabel,
accesskey: copyFunctionKey,
disabled: !functionText,
click: () => copyToTheClipboard(functionText)
click: () => {
const { location: { start, end } } = getFunctionLocation(line);
highlightLineRange({
start: start.line,
end: end.line,
sourceId: selectedLocation.sourceId
});
return copyToTheClipboard(functionText);
}
};

const menuItems = [
Expand Down Expand Up @@ -181,7 +193,12 @@ export default connect(
line,
selectedSource.toJS(),
getSymbols(state, selectedSource.toJS())
)
),
getFunctionLocation: line =>
findClosestScope(getSymbols(state, selectedSource.toJS()).functions, {
line,
column: Infinity
})
};
},
dispatch => bindActionCreators(actions, dispatch)
Expand Down

0 comments on commit b40bb79

Please sign in to comment.