Skip to content

Commit

Permalink
Expand root outline view in outline view by default (#1048)
Browse files Browse the repository at this point in the history
Before this commit, the outline view is drawn with all elements
collapsed by default. This often results in plenty of wasted space in
the UI and low information density.

Instead, as discussed in #693, it would be preferable to draw the
outline view with its first level expanded by default (i.e., displaying
the root node and its immediate children by default).

Issue: #693
  • Loading branch information
joaodinissf authored Aug 13, 2024
1 parent 3ed68da commit 0be2cb2
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,22 @@ protected void refreshTreeContentFromLS() {
return;
}

final int EXPAND_ROOT_LEVEL = 2; // Expansion level that displays root node and its children
if (isQuickOutline) {
viewer.refresh();
viewer.expandToLevel(EXPAND_ROOT_LEVEL);
} else {
TreePath[] expandedElements = viewer.getExpandedTreePaths();
TreePath[] initialSelection = ((ITreeSelection) viewer.getSelection()).getPaths();
viewer.refresh();
viewer.setExpandedTreePaths(Arrays.stream(expandedElements).map(symbolsModel::toUpdatedSymbol)
if (expandedElements.length > 0) {
viewer.setExpandedTreePaths(Arrays.stream(expandedElements).map(symbolsModel::toUpdatedSymbol)
.filter(Objects::nonNull).toArray(TreePath[]::new));
viewer.setSelection(new TreeSelection(Arrays.stream(initialSelection)
.map(symbolsModel::toUpdatedSymbol).filter(Objects::nonNull).toArray(TreePath[]::new)));
viewer.setSelection(new TreeSelection(Arrays.stream(initialSelection)
.map(symbolsModel::toUpdatedSymbol).filter(Objects::nonNull).toArray(TreePath[]::new)));
} else {
viewer.expandToLevel(EXPAND_ROOT_LEVEL);
}
}

if (linkWithEditor) {
Expand Down

0 comments on commit 0be2cb2

Please sign in to comment.