Skip to content

Commit

Permalink
WIP firefox-devtools#4022 - need to get startline of function
Browse files Browse the repository at this point in the history
findFunctionText (utils/function) already has all information
  • Loading branch information
borian committed Sep 17, 2017
1 parent 834deba commit 7101873
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/actions/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function selectSource(id: string, options: SelectSourceOptions = {}) {
}

dispatch(addTab(source.toJS(), 0));

console.log("selectSource ", options.line, options.tabIndex);
return dispatch({
type: "SELECT_SOURCE",
source: source.toJS(),
Expand Down
20 changes: 18 additions & 2 deletions src/components/Editor/EditorMenu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { showMenu } from "devtools-launchpad";
import { isOriginalId } from "devtools-source-map";
import { copyToTheClipboard } from "../../utils/clipboard";
import { findFunctionText } from "../../utils/function";
import getSymbols from "../../utils/parser/getSymbols";

function getMenuItems(
event,
Expand All @@ -13,7 +15,8 @@ function getMenuItems(
jumpToMappedLocation,
toggleBlackBox,
addExpression,
getFunctionText
getFunctionText,
selectSource
}
) {
const copySourceLabel = L10N.getStr("copySource");
Expand Down Expand Up @@ -101,7 +104,20 @@ function getMenuItems(
label: copyFunctionLabel,
accesskey: copyFunctionKey,
disabled: !functionText,
click: () => copyToTheClipboard(functionText)
click: () => {
copyToTheClipboard(functionText);
console.log("responding");
console.log(selectedSource.get("id"), sourceLocation);

console.log("functionText ", functionText, selectedSource.toJS());
selectSource(selectedLocation.sourceId, { line: line + 1 });

// highlightLineRange({
// start: line + 1,
// end: line + 2,
// sourceId: selectedLocation.sourceId
// });
}
};

const menuItems = [
Expand Down
6 changes: 4 additions & 2 deletions src/components/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ class Editor extends PureComponent {
jumpToMappedLocation,
addExpression,
toggleBlackBox,
getFunctionText
getFunctionText,
selectSource
} = this.props;

return EditorMenu({
Expand All @@ -356,7 +357,8 @@ class Editor extends PureComponent {
addExpression,
toggleBlackBox,
getFunctionText,
onGutterContextMenu: this.onGutterContextMenu
onGutterContextMenu: this.onGutterContextMenu,
selectSource
});
}

Expand Down

0 comments on commit 7101873

Please sign in to comment.