debugger icon indicating copy to clipboard operation
debugger copied to clipboard

goto line functionality

Open codehag opened this issue 9 years ago • 10 comments

a user has requested goto line functionality similar to the old debugger

something like adding :100 in the search field to go to line 100

this should be easy to implement using the selectLocation functionality using the current source.

GIST

diff --git a/src/components/App.js b/src/components/App.js
index 1dd5132..ed7e64e 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -100,6 +100,13 @@ class App extends Component {
       L10N.getStr("symbolSearch.search.key2"),
       this.toggleSymbolModal
     );
+
+    // cmd g should toggle go to line
+    shortcuts.on(
+      L10N.getStr("symbolSearch.search.key2"),
+      this.toggleSymbolModal
+    );
+
     shortcuts.on("Escape", this.onEscape);
   }
 
@@ -143,6 +150,30 @@ class App extends Component {
     setActiveSearch("symbol");
   }
 
+  toggleGoToLineModal(_, e: SyntheticEvent) {
+    const {
+      selectedSource,
+      activeSearch,
+      closeActiveSearch,
+      setActiveSearch
+    } = this.props;
+
+    e.preventDefault();
+    e.stopPropagation();
+
+    // this is beautiful. we don't wan to topen if there is no source :)
+    // yay
+    if (!selectedSource) {
+      return;
+    }
+
+    if (activeSearch == "symbol") {
+      return closeActiveSearch();
+    }
+
+    setActiveSearch("line");
+  }
+
   onLayoutChange() {
     if (isVisible()) {
       this.setState({ horizontal: verticalLayoutBreakpoint.matches });
diff --git a/src/components/SymbolModal.js b/src/components/SymbolModal.js
index e515a1b..9db62fa 100644
--- a/src/components/SymbolModal.js
+++ b/src/components/SymbolModal.js
@@ -1,5 +1,10 @@
 // @flow
 
+// copy this file and re-name it to go to line
+
+// the key detail is that enter should call the action `selectSource` with the current
+// selected source and the line
+
 import PropTypes from "prop-types";
 import React, { Component } from "react";
 import { connect } from "react-redux";

codehag avatar Sep 29 '17 10:09 codehag

Agreed, lets find a good UI for this. Chrome uses ctrl+g which is the standard shortcut. They also use their modal, which is a good pattern here. I think they had an alert box until recently :)

Another argument for using the modal is that when we do the editor UX we can implement our unified modal vision, where the prefix ":" triggers line mode, "@" triggers function mode, ...

jasonLaster avatar Sep 29 '17 13:09 jasonLaster

I'd like that (: triggering line mode, etc.) ! IMO # should trigger the function mode though, like before.

nicofrand avatar Sep 30 '17 10:09 nicofrand

Yes, i was thinking this would be nice too

codehag avatar Oct 02 '17 13:10 codehag

Hi everyone! I am looking for my first bug and I am interested to contribute and explore React. I am wondering if this is a good idea to start on this one or would you recommend me some other bug to start with?

svitlana-galianova avatar Oct 03 '17 17:10 svitlana-galianova

@svitlana-galianova we're doing a meetup tonight, i think some people might start it then

jasonLaster avatar Oct 03 '17 22:10 jasonLaster

/claim

at @jasonLaster 's suggestion I'm taking a look at this one, got a bit of a diff going, I'll update soon! Will likely have questions :)

jfo avatar Oct 06 '17 17:10 jfo

Thanks for claiming the issue! :wave:

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

:fox_face: Debugger team!

claim avatar Oct 06 '17 17:10 claim

This was landed. So I'm going to close it.

wldcordeiro avatar Oct 17 '17 20:10 wldcordeiro

Sorry to comment on a closed ticket but I cannot find how to use this feature, with Firefox 58.0b4 (I was told this landed in Firefox 58) ?

nicofrand avatar Nov 27 '17 14:11 nicofrand

yep, cmd+:

jasonLaster avatar Nov 27 '17 17:11 jasonLaster