Skip to content

#149034 Select all when shift click in outline #161359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,20 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
return this._outlineModel?.uri;
}

async reveal(entry: DocumentSymbolItem, options: IEditorOptions, sideBySide: boolean): Promise<void> {
async reveal(entry: DocumentSymbolItem, options: IEditorOptions, sideBySide: boolean, entireSelection?: boolean): Promise<void> {
const model = OutlineModel.get(entry);
if (!model || !(entry instanceof OutlineElement)) {
return;
}

// #149034 Use entire selection range conditionally (i.e. When user is holding the Shift key)
const range = entireSelection ? entry.symbol.selectionRange : Range.collapseToStart(entry.symbol.selectionRange);

await this._codeEditorService.openCodeEditor({
resource: model.uri,
options: {
...options,
selection: Range.collapseToStart(entry.symbol.selectionRange),
selection: range,
selectionRevealType: TextEditorSelectionRevealType.NearTopIfOutsideViewport,
}
}, this._editor, sideBySide);
Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/contrib/outline/browser/outlinePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ export class OutlinePane extends ViewPane {

// feature: reveal outline selection in editor
// on change -> reveal/select defining range
this._editorControlDisposables.add(tree.onDidOpen(e => newOutline.reveal(e.element, e.editorOptions, e.sideBySide)));
this._editorControlDisposables.add(tree.onDidOpen(e => {
// feature #149034: If shift key, tell reveal to use entire selection
const entireSelection = (e.browserEvent instanceof PointerEvent && (e.browserEvent as PointerEvent).shiftKey);
newOutline.reveal(e.element, e.editorOptions, e.sideBySide, entireSelection);
}));
// feature: reveal editor selection in outline
const revealActiveElement = () => {
if (!this._outlineViewState.followCursor || !newOutline.activeElement) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/services/outline/browser/outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface IOutline<E> {
readonly activeElement: E | undefined;
readonly onDidChange: Event<OutlineChangeEvent>;

reveal(entry: E, options: IEditorOptions, sideBySide: boolean): Promise<void> | void;
reveal(entry: E, options: IEditorOptions, sideBySide: boolean, entireSelection?: boolean): Promise<void> | void;
preview(entry: E): IDisposable;
captureViewState(): IDisposable;
dispose(): void;
Expand Down