princejwesley / Mancy

>_ Electron based NodeJS REPL :see_no_evil:
http://mancy-re.pl
MIT License
2.63k stars 134 forks source link

Auto expand object/array results #121

Open Kikobeats opened 8 years ago

Kikobeats commented 8 years ago

Maybe this options is implemented and I didn't find how to enable it.

Basically instead of write something and click in the object return to be expanded, expanded automatically:

screen shot 2016-04-18 at 20 58 22

Maybe could be possible setup a N depth level in settings

princejwesley commented 8 years ago

Maybe this options is implemented and I didn't find how to enable it.

It is not implemented. At the moment, we don't have the contextual information like depth of the element.

Questions
  1. Which one is more useful? Top level or N level ?
  2. What would be the max level If we provide support for N levels? ( Remember, we will lose lazy rendering of elements upto N levels). There is a performance issue for rendering some big objects with more than one self aliases when N is big. (e.g. global with GLOBAL, global and root aliases)
  3. Do we need depth support for console output and global environment section ?
  4. I think, its good to ignore depth support for nested special views like regex, buffer & charts.
princejwesley commented 8 years ago

[Off topic] I suggest to use regex viewer for the above example.

image

Kikobeats commented 8 years ago

Actually I don't know how prints in the REPL is implemented, but I think that util.inspect (depth option) could be useful for do it: https://nodejs.org/api/util.html#util_util_inspect_object_options

This code is an example of copy/paste from internet. Although your offtopic is great sugar for the REPL, you need think that (IMHO) copy/paste is a universal driven development 😛.

princejwesley commented 8 years ago

@Kikobeats As per current implementation, there is no depth limit as such. Its lazy and therefore, the stack won't grow and is fast since we are serving nested object's view only when the user interested in viewing it. Configuration for top level auto expansion is good option. 👍 I don't see issues in carrying depth info around while building object tree.

Kikobeats commented 8 years ago

Hmm but click in ">" is more a frontend issue, or how to resolve it?

antonyr commented 8 years ago

@princejwesley I think it is a good idea to expand and show the result up to 2 levels. This should also be driven only through a setting. It is also good to have depth setting for console. Yes we can ignore depth support for Regex, Charts and Buffers

princejwesley commented 8 years ago

@Kikobeats > carries a initial state that has to be toggled based on the configuration and pass on the current depth + 1 level to its immediate children.

Only problem is, we should limit the max depth level(may be 5 or 8). Reasons are,

  1. JS objects are not directed acyclic graphs(DAGs). Objects may have reference loops(In util#inspect case, util#inspect does know the circular references. In our case, objects are free and are built recursively on demand).
  2. Too much depth expansion is not going to help. User has to extract/pull the deep nested object to have better view.
holyjak commented 7 years ago

Would it be possible to implement this? How difficult is it? It would be really useful!