Feature request: be able to set hierarchy of document outline headers that overrides code nesting

When writing large R scripts, the document outline can be extremely helpful, especially nesting the headers to achieve a nice easily-navigated hierarchical structure

When all headers are located outside of code, this nesting works nicely:

# Header 1 ----
## Sub-header A ----
## Sub-header B ----
# Header 2 ----

produces:

  • Header 1
    • Sub-header A
    • Sub-header B
  • Header 2

However, when headers are located inside of nested code, the code hierarchy overrides the nesting of the headers:

# Header 1 ----
if(condition) {
  ## Sub-header A ----
  if(A) {
     #do something
  ## Sub-header B ----
  } else if (B) {
     #do something
  }
# Header 2 ----
} else {
  #do something
}

produces:

  • Header 1
    • Sub-header A
      • Sub-header B
    • Header 2

I would propose that there be some way of allowing headers to set their nesting level regardless of the code they're located in. Perhaps some additional character that forces things so that the number of # sets the hierarchical level of the outline regardless of where they are in the code

Hello, if you have a bug report or feature request to make for RStudio, the best place for it would be the GitHub repository.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.