Skip to content

Commit

Permalink
Fix disappearing sort button in outline view (fix eclipse#1091)
Browse files Browse the repository at this point in the history
Previously, the sort button was only active if the active part was the outline view (activePart had to be instanceof OutlineView). As soon as an editor became active, the visibleWhen expression became false and the sort button disappeared. The check was done by the expression definition named activePartHasCNFOutlinePage.

I added a new expression definition named activeEditorHasCNFOutlinePage. I changed the visibleWhen expression to only check if the (last) active editor (that does not necessarily has to be in focus) has an outline page of type CNFOutlinePage. The remaining checks using the expression activePartHasCNFOutlinePage are left unchanged.
  • Loading branch information
travkin79 committed Aug 30, 2024
1 parent feab5a6 commit 0b4afd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion org.eclipse.lsp4e/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
<menuContribution allPopups="false" locationURI="toolbar:org.eclipse.ui.views.ContentOutline?after=additions">
<command commandId="org.eclipse.lsp4e.toggleSortOutline" style="toggle" label="%command.toggle.outline.sort.label">
<visibleWhen>
<reference definitionId="org.eclipse.lsp4e.activePartHasCNFOutlinePage" />
<reference definitionId="org.eclipse.lsp4e.activeEditorHasCNFOutlinePage" />
</visibleWhen>
</command>
</menuContribution>
Expand Down Expand Up @@ -760,6 +760,15 @@
</and>
</with>
</definition>
<definition
id="org.eclipse.lsp4e.activeEditorHasCNFOutlinePage">
<with
variable="activeEditor">
<test
property="org.eclipse.lsp4e.hasCNFOutlinePage">
</test>
</with>
</definition>
<definition id="org.eclipse.lsp4e.editorHasLanguageServer">
<or>
<with variable="editorInput">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;

public class HasCNFOutlinePage extends PropertyTester {

Expand All @@ -22,6 +24,10 @@ public boolean test(@Nullable Object receiver, String property, Object[] args, @
if (receiver instanceof ContentOutline outline) {
return outline.getCurrentPage() instanceof CNFOutlinePage;
}
if (receiver instanceof IEditorPart editor) {
IContentOutlinePage outlinePage = editor.getAdapter(IContentOutlinePage.class);
return outlinePage instanceof CNFOutlinePage;
}
return false;
}

Expand Down

0 comments on commit 0b4afd1

Please sign in to comment.