Skip to content
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

Add find all button #7559

Open
wants to merge 2 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
6 changes: 6 additions & 0 deletions src/vs/editor/contrib/find/findWidget.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@
background-image: url('images/chevron-next-light.svg');
}

.monaco-editor .find-widget .find-all {
width: auto;
padding: 0 .5em;
text-align: center;
}

.monaco-editor .find-widget .disabled {
opacity: 0.3;
cursor: default;
Expand Down
19 changes: 19 additions & 0 deletions src/vs/editor/contrib/find/findWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
export interface IFindController {
replace(): void;
replaceAll(): void;
selectAllMatches(): void;
getGlobalBufferTerm(): string;
}

const NLS_FIND_INPUT_LABEL = nls.localize('label.find', "Find");
const NLS_FIND_INPUT_PLACEHOLDER = nls.localize('placeholder.find', "Find");
const NLS_ALL_MATCH_BTN_LABEL = nls.localize('label.allMatchButton', "Select all matches");
const NLS_FIND_ALL = nls.localize('label.findAll', "Find All");
const NLS_PREVIOUS_MATCH_BTN_LABEL = nls.localize('label.previousMatchButton', "Previous match");
const NLS_NEXT_MATCH_BTN_LABEL = nls.localize('label.nextMatchButton', "Next match");
const NLS_TOGGLE_SELECTION_FIND_TITLE = nls.localize('label.toggleSelectionFind', "Find in selection");
Expand Down Expand Up @@ -118,6 +121,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas

private _toggleReplaceBtn!: SimpleButton;
private _matchesCount!: HTMLElement;
private _allMatchBtn!: SimpleButton;
private _prevBtn!: SimpleButton;
private _nextBtn!: SimpleButton;
private _toggleSelectionFind!: SimpleCheckbox;
Expand Down Expand Up @@ -447,6 +451,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas

let findInputIsNonEmpty = (this._state.searchString.length > 0);
let matchesCount = this._state.matchesCount ? true : false;
this._allMatchBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);
this._prevBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);
this._nextBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);
this._replaceBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
Expand Down Expand Up @@ -967,6 +972,17 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
this._matchesCount.className = 'matchesCount';
this._updateMatchesCount();


// Find All button
this._allMatchBtn = this._register(new SimpleButton({
label: NLS_ALL_MATCH_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.SelectAllMatchesAction),
className: 'find-all',
onTrigger: () => {
this._controller.selectAllMatches();
},
onKeyDown: (e) => {}
}));

// Previous button
this._prevBtn = this._register(new SimpleButton({
label: NLS_PREVIOUS_MATCH_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.PreviousMatchFindAction),
Expand Down Expand Up @@ -994,6 +1010,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
actionsContainer.appendChild(this._matchesCount);
actionsContainer.appendChild(this._prevBtn.domNode);
actionsContainer.appendChild(this._nextBtn.domNode);
// Insert find all button
actionsContainer.appendChild(this._allMatchBtn.domNode);
this._allMatchBtn.domNode.appendChild(document.createTextNode(NLS_FIND_ALL));

// Toggle selection button
this._toggleSelectionFind = this._register(new SimpleCheckbox({
Expand Down