You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Source toolbar's previous/next section buttons follow the active document's chunk commands, not their own document #19895
The source editor toolbar's Go to previous section/chunk and Go to next section/chunk buttons have two visibility rules that disagree, and whichever ran last wins.
TextEditingTargetWidget.adaptToFileType shows them only where fileType.canGoNextPrevSection() is true, which covers R Markdown, Quarto, and R presentations (TextEditingTargetWidget.java#L1473-L1474).
TextEditingTargetWidget.manageToolbarSizes then sets them from commands_.goToNextChunk().isVisible() / goToPrevChunk().isVisible() (#L1738-L1739). It runs on every resize and tab activation, so it usually has the last word.
The second rule has two problems:
It reads the wrong commands. The buttons run goToPrevSection / goToNextSection, but their visibility comes from the chunk commands. Both pairs are offered for every file type that can show a scope tree (TextFileType.java#L477-L486), so in practice the buttons appear on R scripts too, where the first rule hides them.
It reads global state.goToNextChunk / goToPrevChunk are dynamic commands whose visibility follows the active document (SourceColumnManager.dynamicCommands_), not the document whose toolbar is being laid out. With two source columns, a refit of the inactive column's toolbar shows or hides its buttons according to the other column's document. For example, a plain-text file next to an active R script would get the buttons. This part is from reading the code and hasn't been reproduced.
Observed
On main, an R script in a Source pane wide enough to fit them shows both buttons. Section navigation works there via # Section ---- comments.
To decide
Which documents should have these buttons:
If it's only R Markdown, Quarto, and R presentations (canGoNextPrevSection()), R scripts lose them. That's a visible change.
If it's every document with a scope tree, canGoNextPrevSection() is the stale rule.
Either way, the toolbar code should read the document's own file type, or its column's SourceAppCommand, rather than the global commands.
Found while reviewing the source toolbar fitting changes on bugfix/editor-toolbar-overflow; that branch keeps the existing rule unchanged.
Activity