debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[ProjectSearch] search the source when a match is selected

Open jasonLaster opened this issue 9 years ago • 6 comments

When clicking on a line result in the search results, it would be nice if the line or keyword instance would be highlighted when the source is opened.

Atom does this really nicely when you select a match. For us it would be as easy as firing this action

1. project search

Screen Shot 2017-08-30 at 5.43.16 PM.png

2. bin/mochi

Screen Shot 2017-08-30 at 5.43.09 PM.png

jasonLaster avatar Aug 30 '17 21:08 jasonLaster

/claim

AlexisDeschamps avatar Jan 20 '18 15:01 AlexisDeschamps

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Jan 20 '18 15:01 claim

export class ProjectSearch extends Component<Props, State> {

   selectMatchItem = (matchItem: Match) => {
     this.props.selectLocation({ ...matchItem });
+    this.props.doSearch(this.state.inputValue, editor);
   };

   getResults = (): Result[] => {

This change will add the search on source selection, but the editor is not available within this component and would need to be obtained.

AlexisDeschamps avatar Jan 20 '18 18:01 AlexisDeschamps

I am not sure if this helps, but anyway The old FireFox debugger had this feature as you can see in this GIF :


https://i.imgur.com/yTMfi8t.gif


Comparing to the new debugger which doesn't highlight the matching clause :


https://i.imgur.com/4NBhQG2.gif


urielha avatar Mar 19 '18 12:03 urielha

Thanks @urielha

jasonLaster avatar Mar 19 '18 13:03 jasonLaster

I think we can get the editor if we set it in module state:

diff --git a/src/utils/editor/index.js b/src/utils/editor/index.js
index 00d689a..fa6e15c 100644
--- a/src/utils/editor/index.js
+++ b/src/utils/editor/index.js
@@ -20,6 +20,20 @@ import type { AstLocation } from "../../workers/parser";
 import type { EditorPosition, EditorRange } from "../editor/types";
 import type { Location } from "../../types";

+let editor = null;
+
+export function setEditor(_editor) {
+  editor = _editor;
+}
+
+export function getEditor() {
+  return editor;
+}
+
+export function clearEditor() {
+  editor = null;
+}
+
index 92fcfc3..963e920 100644
--- a/src/actions/navigation.js
+++ b/src/actions/navigation.js
@@ -37,6 +37,7 @@ export function willNavigate(event: Object) {
     await sourceMaps.clearSourceMaps();
     clearWasmStates();
     clearDocuments();
+    clearEditor();
     clearSymbols();
     clearASTs();
     clearScopes();

jasonLaster avatar Mar 26 '18 16:03 jasonLaster