Repository navigation
navigate to bookdown xrefs in omni-search - #7302
Conversation
| } | ||
|
|
||
| // figure out appropriate source item type | ||
| SourceItem::Type sourceType = SourceItem::None; |
There was a problem hiding this comment.
@jjallaire: are there any other reference types I should handle here?
There was a problem hiding this comment.
All the types are here (save for eq which I appear to have forgotten!): https://github.com/rstudio/rstudio/blob/master/src/gwt/panmirror/src/editor/src/api/xref.ts#L99
cfc6a8b to
fc8f15f
Compare
jjallaire
left a comment
There was a problem hiding this comment.
Looks like the right approach, see a few comments about treatment for ids/titles in the find UI + some additional types to look out for.
| EnumValue = 5, | ||
| Namespace = 6 | ||
| Namespace = 6, | ||
| Section = 7, |
There was a problem hiding this comment.
There's also equations and theorems (although the latter obscure enough that we probably don't need navigation for it).
| EnumValue = 5, | ||
| Namespace = 6 | ||
| Namespace = 6, | ||
| Section = 7, |
There was a problem hiding this comment.
Do we want to distinguish between heading levels here? (Hadley had asked for distinguishing headings levels in xref completions b/c it's helpful context). Paul could do separate icons for H1-H6.
There was a problem hiding this comment.
Even just h1 vs h2 vs everything else would be useful
| } | ||
|
|
||
| // figure out appropriate source item type | ||
| SourceItem::Type sourceType = SourceItem::None; |
There was a problem hiding this comment.
All the types are here (save for eq which I appear to have forgotten!): https://github.com/rstudio/rstudio/blob/master/src/gwt/panmirror/src/editor/src/api/xref.ts#L99
| } | ||
|
|
||
| // form appropriate text for display | ||
| std::string displayText = title; |
There was a problem hiding this comment.
I'm torn as to whether we should be showing IDs here, at least for figures, tables, and equations -- as that's the 'identifier' that's being searched for (i.e. for functions we don't show the roxygen title if available we show the name of the function). I've also seen that figure and table captions can get quite long (even multiple sentences) and I think the id would be a better mental "bookmark' in the case cases.
For section I can see the argument that we should use the actual title (since the id is typically algorithmically derived from the title).
There was a problem hiding this comment.
How about both, like title (#id) ? Or is that likely to be too long?
There was a problem hiding this comment.
I think it will be too long (a section title would typically be ~ 10-30 characters which is already over the effective limit for the UI).
There was a problem hiding this comment.
If we think displaying the ID is necessary we could truncate the section title and always append the ID.
There was a problem hiding this comment.
I'd say try it without, and then if it's frustrating we figure out how to add it.
There was a problem hiding this comment.
I think no ID for sections/headers to start with is fine, but we definitely should use the IDs for figures, tables, and equations. In those cases that's the actual "symbol" they are navigating to (it's the chunk label).
There was a problem hiding this comment.
Sorry, to re-iterate: do we want to be able to search based on the contents of the caption (e.g. for a figure), or only based on the figure ID?
There was a problem hiding this comment.
I think we should search based on contents, but we should show the id in the list
| return target; | ||
|
|
||
| // nothing to do if the query doesn't have ':' | ||
| int colonIndex = query.indexOf(":"); |
There was a problem hiding this comment.
Perhaps it's accounted for elsewhere, but do we want to have fig:, tab:, etc. filter on xref type?
There was a problem hiding this comment.
That would be nice but it's not very discoverable, so hard to know if people would ever use it.
There was a problem hiding this comment.
That's true. Probably not worth it then.
6043dee to
b2a0357
Compare
|
Going to merge this now (to avoid future merge conflicts); we can tweak the display post-merge. |
This PR makes it possible to navigate to sections, figures and tables within a bookdown project via the fuzzy finder.
Some questions worth answering before final merge: