0

My intention is to facilitate investigation of deeply buried code.

For example, an error is thrown with message "ABC Error" and if | is where the cursor is:

function handleRequest(req) {
  let param = req.toJSON();
  if ( param['get'] ) {
    param['data'].sanitize()
      .then( d => {
        ...
      })
      .catch( e => { alert("ABC Error") });|

I want the end result to be something like

function handleRequest(req) {
  if ( param['get'] ) {
    param['data'].sanitize()
      .catch( e => { alert("ABC Error") });|

The algorithm would be like, getting the indent('.') and find lines above and fold it -- unless it has a lower indent, and update the current indent until the current indent level reaches 0. (I know that this would not work very well with else clauses)

Any ideas are welcomed.

  • Just to clarify: are you looking for a command/function/mapping that creates a new fold when using foldmethod=manual? I'm also not sure what you mean by "update the current indent until the current indent level reaches 0" – Rich Nov 13 '17 at 14:27
  • I need a way to fold the lines so I can see how the program flows (in this case, how the error is thrown) -- so any of command / function / mapping / plugin is ok. The algorithm is going from the current line (ideally) top of the function, like .catch has indent level 3, and go up fold the lines (since .then and subsequent lines are 3 or above. Then we show param['data']... as it is level 2. So update the current indent to 2 and continue go up. Level 1 for if ( param.. thus folding lines >=1 above it. Please feel free to edit to make it clearer :) – Sunny Pun Nov 13 '17 at 14:35
  • I think I understand your algorithm now. But I'm still unclear on if you want something that you manually invoke in specific situations when you want to create a fold, or something that automatically creates folds for an entire file (using syntax or expression folding). – Rich Nov 13 '17 at 14:55
  • Oops sorry. I want something that can be manually invoked. – Sunny Pun Nov 13 '17 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.