reposplit icon indicating copy to clipboard operation
reposplit copied to clipboard

[REQUEST] Indexing/search ability in code

Open vaidsu opened this issue 8 years ago • 3 comments

First of all, this is great work.

I love it, it looks like I am opening the code in a live editor and checking without having to pull.

I am sure you have searching in your roadmap?

Do you? If yes, can you please provide some hints so I can try contributing?

vaidsu avatar May 22 '17 20:05 vaidsu

Hi Vaidsu,

Thanks for the feedback, I'm glad you like it :) Unfortunately I haven't been able to work on it lately, but I plan to pick it up soon with the pending bugs/feature requests. To be honest, search was not on the roadmap but it makes a lot of sense to have it. Let's discuss the possible approaches and different aspects.

UI/UX

Input box

Where/How to present the search input box. Options:

  1. Search input textbox always present at the bottom of the left pane ( where the tree is). Whenever your query matches a file, only the matching files will show in the tree. If the box is empty, the whole tree is shown(just like now)
  2. Some sort of keyboard shortcut toggles the input box. It could be rendered as an overlay anywhere for example.

I would suggest 1

Questions

  • How are the matches being presented? ie. The match between your query and the matching file content. Should it replace the open file panes? Should it all live in an overlay modal-like?

I would suggest some sort of slightly shadowed overlay above the file editor panels for starters.

Actual search

Currently Reposplit just downloads the file tree, and requests the file contents as you need them on demand. Therefore client-side search cannot be done for the whole repo unless all file contents are downloaded. So the approaches are:

  1. Download all file contents and pattern match the search query against it.
  2. Pattern-match/search only among the files the user already downloaded/viewed
  3. Use Github's search API ( Note that it has its limitations )

I would suggest to start with 3, see how far it can go

git-toni avatar May 23 '17 08:05 git-toni

@git-toni Thanks a lot for your response. I have been using this very frequently for the past few days. It is quite useful really, much better than clicking into pages of github breadcrumbs link and navigating.

I think searching could just be started as a simple wildcard search across the file, which is very similar to the search in the GitHub. I agree it will miss some contents usually whenever I search, and thats probably what you had explained above.

I haven't used the search API yet, let me play with it. Just basic question, is it same as the search we would usually do in GitHub ? I mean the search results?

Search input textbox always present at the bottom of the left pane ( where the tree is).

This is good enough. Currently I use the Browser search (cmd + f), kind of naive but it works faster and better than the actual GitHub search if I know which file.

I would suggest some sort of slightly shadowed overlay above the file editor panels for starters.

I am just providing my standpoint of usage. Keeping it very simple, like you mentioned a simple highlight on top of the file in the tree view and then doing the same re-search when a file is opened (since you mentioned its on-demand request per file and not full download) and highlight like how the browser highlights. In fact, if you wish to simplify further just providing which file is very useful to start with, where one can use the Browser to find further. I know that doesn't complete the feature but might help.

Contributing

I have only used Redux, MobX is slightly newer to me, I know the conceptual difference. Let me try forking the code and play with it. Its kind of magical on how you are finding which repo I am viewing etc. :) Need to understand that to get into this.

Thanks again for response.

vaidsu avatar May 23 '17 17:05 vaidsu

Hi, Sorry for the late reply.

is it same as the search we would usually do in GitHub ? I mean the search results?

I haven't tried it, but judging by the documentation, it seems so yes.

and highlight like how the browser highlights. In fact, if you wish to simplify further just providing which file is very useful to start with, where one can use the Browser to find further. I know that doesn't complete the feature but might help.

I'd find the way the browser(or Vim Chrome plugin in my case) highlights a great option, but I'm not sure the current syntax highlighter library (react-syntax-highlighter based on lowlight) will allow us to highlight some words inside the viewer. I'm not completely happy with this library so if highlighting is not allowed, this would be an added reason to move to something else :)

MobX is slightly newer to me, I know the conceptual difference

I also worked with Redux before because I didn't want to "trust" the feeling of MobX magic. But after a few projects with it, you learn how it works and IMHO you can end up with essentially the same control over your state transitions in a more concise and flexible way ( I'd suggest you to use useStrict(true) and any state changer with @action). I've got a very minimal JWT-Authenticated Frontend repo with React+MobX, unfortunately it's assuming you have a backend server running at :3000 which I don't provide in the repo yet. Just in case you find it useful, although I'm sure there's 100s of better resources.

git-toni avatar May 25 '17 11:05 git-toni