Skip to content

Add find all button - #7559

Open
Yisi (yisibl) wants to merge 2 commits into
microsoft:mainfrom
yisibl:add-find-all-button
Open

Yisi (yisibl) wants to merge 2 commits into
microsoft:mainfrom
yisibl:add-find-all-button

Conversation

@yisibl

@yisibl Yisi (yisibl) commented Jun 11, 2016 •

Copy link
Copy Markdown
Contributor

Fixed #14836
demo

@mention-bot

Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified Asuka (@Inori) and alexandrudima to be potential reviewers

@msftclas

Hi Yisi (@yisibl), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas

Yisi (@yisibl), Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

"label.nextMatchButton": "下一个匹配",
"label.noResults": "无结果",
"label.previousMatchButton": "上一个匹配",
"label".allMatchButton": "选中所有匹配",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't modify locaization files ourselves, only touch the English version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peng Lyu (@rebornix) Do you mean that do not modify the localization file? Should I submit a PR to increase localization translation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, just leave it there, it will be handled by the localization team.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, just leave it there, it will be handled by the localization team.

@yisibl Yisi (yisibl) Jun 12, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!
By the way, how do I open a localized UI to vscode after the source code is compiled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the localized changes.

@yisibl

Copy link
Copy Markdown
Contributor Author

alexandrudima This can be merge?

@alexdima Alexandru Dima (alexdima) added the ux User experience issues label Jun 26, 2016
@alexdima

Copy link
Copy Markdown
Member

I would like to bring in our UX folks on this, rather than just merging it in and get their advice on how we can add functionality to the find widget without overdoing it.

Steven Clarke (@stevencl) Brad Gashler (@bgashler1) Can I please get your opinion on this proposal?

@yisibl

Copy link
Copy Markdown
Contributor Author

alexandrudima Thanks!

@stevencl

Copy link
Copy Markdown
Member

I really like the idea. We might consider doing something similar to Visual Studio. Instead of three separate buttons for find next, find previous and find all, VS has a button with a drop down that allows you to select the specific action you want to use. So it would look something like this mockup (showing what the user sees when they click the drop down):

image
The idea would be that you click on the drop down next to the button to run and then change the command. So if you click Find Previous in the drop down, the button changes to the Find Previous button. If you click Find All, the button changes to the Find All button etc.

Brad Gashler (@bgashler1) might have some other, better ideas. I haven't spoken with him about this today.

@yisibl

Yisi (yisibl) commented Jun 28, 2016 •

Copy link
Copy Markdown
Contributor Author

Steven Clarke (@stevencl)

I am more inclined to the 100% width of the search box, and the height is adaptive. Now the search box is too short, and the preparation of the code when you may often need to search for a relatively long code fragment. If it is a 100% width search box, then there is no need to fold(drop down) the buttons.

Sublime Text:

Sublime


By the way, usually the focus of our vision is on the left, especially when full screen writing code, usually we will set up more than 80 characters automatically wrap. So now the search box aligned to the right, I think the user experience is not good.

Anyway I expect the next version can be added to find all button.

Thanks!

@stevencl

Copy link
Copy Markdown
Member

Thanks Yisi (@yisibl). I understand the points you are making about the current find experience.

As you've pointed out, Sublime has a very different user experience for find and find in files. We use the small box for find and a viewlet for find in files so that we minimise the extent to which we interfere with the code that the user is browsing.

In order to accommodate richer find interactions such as the one you are proposing here we need to ensure that we minimise the amount of code we obscure when we draw the find UI. Hence my suggestion above (and the reason why we align the find UI to the right).

So without any major modifications to the current find UI, I would recommend the drop down button to expose the Find All command. That way we incorporate the new functionality without requiring major changes to the overall find UX.

@rebornix

Copy link
Copy Markdown
Contributor

I'll review this PR in next iteration when I do full width find widget.

@yisibl

Copy link
Copy Markdown
Contributor Author

Peng Lyu (@rebornix) Where's the plan for "full width find widget"?

@ghost

Copy link
Copy Markdown

Steven Clarke (@stevencl) use for all (∀) symbol.
Captura de tela_2021-04-15_22-25-37

@ghost

Copy link
Copy Markdown

Best to design another codicon for it

@ghost

Deleted user (ghost) commented Sep 17, 2021 •

Copy link
Copy Markdown

I have logged a issue for adding a bespoke icon specifically for this pull and other uses of "select all" in the UI

@ghost

Copy link
Copy Markdown

It's embarrassing that this is 6 years old!

@miguelsolorio Miguel Solorio (miguelsolorio) removed their assignment Jul 19, 2022
@byehack

byehack commented Oct 5, 2022

Copy link
Copy Markdown

Find all button in other places is usually for show list of them, not select!
Btw I hope it will add by #158598 (comment)

image

Just an idea:
Change the color of number of founds and make it clickable.
Click on it should go to search panel with seed of current search and just include current file.
(It could have support CTRL+click to find in all files.)
Details can go under hovering.

Also, there is an extension currently do this but main problem there is no way to back previous state of search panel. (it could solve with using search editor)

@zm-cttae

Copy link
Copy Markdown

I personally think the caption should be "Select All Matches" like the exploration done in #14836.
The icon could just be expand-all or plus which is the best analog in the UI for "multi-target actions"

@zm-cttae ZM (zm-cttae) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yisi (@yisibl) This conflicts with the new orthogonal "Find all" new window button implemented #128915 and the naming is internally inconsistent.

As some context, the #14836 issue split into two feature requests:
1. "Find all" `new-file` icon to launch a new search editor file
2. "Select all matches" `expand-all` icon

I'll try and make some suggestions ... this review should hopefully get us a working "select all" button.

@zm-cttae

ZM (zm-cttae) commented Feb 2, 2023 •

Copy link
Copy Markdown

Nvm I will make a PR to your fork branch and see if I can reup this. yisibl#1

@heartacker

Copy link
Copy Markdown
Contributor

hi, Peng Lyu (@rebornix) , could you please take a look

@ruru-m07 ruru (ruru-m07) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@vivodi

vivodi commented Dec 28, 2024

Copy link
Copy Markdown

Is this still relevant?

@sijanthapa171

Copy link
Copy Markdown

👍

@6space7 Some guy (6space7) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR! 🤝

@vjaykrsna

Copy link
Copy Markdown

can't believe pull request from 2016 is still open.
I am not sure how many of such are lost there in the crowd of 5k issues and 750+ open PR
seems like microsoft isn't using github copilot themselves to keep things tidy

@joaomoreno

Copy link
Copy Markdown
Contributor

This is supported today by pressing Alt Enter in the Find Widget. Do we really need a button for this?

@zm-develops

ZM (zm-develops) commented Nov 4, 2025 •

Copy link
Copy Markdown

I would be OK with having this shortcut only, but usually, keyboard shortcuts are esoteric to me.
Not as intuitive as a button with alt shortcut text.

@joaomoreno

Copy link
Copy Markdown
Contributor

What would resonate with me, instead of having a dedicated button visible all the time: while holding Alt, the user can either press Enter (supported today) or find that the two arrows suddenly transform into a single Find All button, ready to be clicked.

Holding Alt to show alternative actions is a pattern we already have in a lot of places around the workbench.

Screen.Recording.2025-11-05.at.16.51.16.mov

@nidhishgajjar

Copy link
Copy Markdown

Orb Code Review (powered by GLM-4.7 on Orb Cloud)

Summary

This PR adds a "Find All" button (labeled "Select all matches") to VS Code's find widget. The button appears to allow users to select all matches of the search term in the editor. The implementation adds the UI button, styling, and calls a new selectAllMatches() method on the find controller. However, the PR appears incomplete as it doesn't show the implementation of the selectAllMatches() method itself.

Architecture

src/vs/editor/contrib/find/findWidget.css (lines 19-23)

New button styling:

.monaco-editor .find-widget .find-all {
    width: auto;
    padding: 0 .5em;
    text-align: center;
}
  • Adds styling for the new "find-all" button
  • Sets auto width, 0.5em padding, and centered text alignment

src/vs/editor/contrib/find/findWidget.ts

Interface extension (line 36):

  • Adds selectAllMatches(): void to the IFindController interface
  • This requires the controller implementation to provide this method

Localization strings (lines 42-43):

const NLS_ALL_MATCH_BTN_LABEL = nls.localize('label.allMatchButton', "Select all matches");
const NLS_FIND_ALL = nls.localize('label.findAll', "Find All");
  • Adds two new localized strings for the button
  • One for the button label (with keybinding), one for the button text

Button declaration (line 51):

  • Declares private _allMatchBtn!: SimpleButton; as a class member

Button state management (line 59):

this._allMatchBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);
  • Enables the button only when:
    • The find widget is visible
    • The find input is non-empty
    • Matches are found (matchesCount is true)
  • This ensures the button is only active when there are matches to select

Button creation (lines 68-76):

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) => {}
}));
  • Creates the button with the localized label and keybinding
  • Uses the 'find-all' CSS class
  • Calls this._controller.selectAllMatches() on click
  • Empty onKeyDown handler (no keyboard handling)

UI insertion (lines 85-87):

actionsContainer.appendChild(this._allMatchBtn.domNode);
this._allMatchBtn.domNode.appendChild(document.createTextNode(NLS_FIND_ALL));
  • Appends the button's DOM node to the actions container
  • Adds "Find All" text to the button

Issues

findWidget.ts:73 — critical — Missing implementation of selectAllMatches()

The PR adds the UI button and calls selectAllMatches() on the controller, but doesn't show the implementation of this method:

onTrigger: () => {
    this._controller.selectAllMatches();  // Method implementation not shown
},

Problems:

  1. Incomplete PR: The PR shows the UI changes but not the actual functionality. The selectAllMatches() method is added to the interface but not implemented.

  2. Action ID reference: The code references FIND_IDS.SelectAllMatchesAction for the keybinding label, but there's no definition of this action ID in the diff.

  3. Functionality unknown: Without the implementation, it's unclear what selectAllMatches() does:

    • Does it select all match ranges in the editor?
    • Does it create a multi-cursor at all match positions?
    • Does it highlight all matches?
    • Does it collect all matches into a list?

Recommendations:

  1. Add the implementation of selectAllMatches() in the find controller

  2. Define the action FIND_IDS.SelectAllMatchesAction with its keybinding

  3. Add tests for the new functionality to ensure it works correctly


findWidget.ts:87 — style — Direct DOM manipulation

The code directly manipulates the DOM to add text to the button:

this._allMatchBtn.domNode.appendChild(document.createTextNode(NLS_FIND_ALL));

Issues:

  1. Inconsistent with other buttons: Other buttons use the label property in the SimpleButton constructor. Why is this different?

  2. Fragile: Direct DOM manipulation is brittle and may break if the SimpleButton implementation changes.

Suggestion:

Either:

  1. Use the label property consistently:
this._allMatchBtn = this._register(new SimpleButton({
    label: NLS_FIND_ALL,
    className: 'find-all',
    onTrigger: () => {
        this._controller.selectAllMatches();
    },
    onKeyDown: (e) => {}
}));
  1. Explain why this is different with a comment if there's a specific reason for the direct DOM manipulation.

findWidget.ts:75 — style — Empty keyboard handler

The onKeyDown handler is empty:

onKeyDown: (e) => {}

Question: Should this handle keyboard events like the other buttons? If not, why not? If yes, what should it do?

Suggestion: Either:

  1. Remove the onKeyDown property if it's not needed:
this._allMatchBtn = this._register(new SimpleButton({
    label: NLS_ALL_MATCH_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.SelectAllMatchesAction),
    className: 'find-all',
    onTrigger: () => {
        this._controller.selectAllMatches();
    }
}));
  1. Add proper keyboard handling if needed (e.g., Enter key to trigger)

findWidget.css:19-23 — style — Specificity could be improved

The CSS selector uses high specificity:

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

Suggestion: Consider if this is necessary or if a simpler selector would work:

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

However, if the higher specificity is needed to override other styles, keep it as is.


findWidget.ts:59 — logic — Button enable/disable logic

The button is enabled only when:

this._allMatchBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);

Question: Is this the correct behavior? Should the button be enabled even if there are no matches (0 matches found)?

Consideration:

  • If the button selects all matches, it makes sense to disable it when there are no matches.
  • However, if the button has other behavior (e.g., searching all files), it might need different logic.

Recommendation: Document the intended behavior in a comment:

// Enable the button only when there are matches to select
this._allMatchBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);

Cross-file Impact

  • Breaking changes: None. This is a pure addition.

  • User experience: Adds a new button to the find widget that allows selecting all matches. This could be useful for bulk operations on all matches.

  • Accessibility: The button should have proper ARIA attributes. Check if the SimpleButton component handles this automatically or if additional work is needed.

  • Keyboard navigation: The button can be tabbed to (assuming standard button behavior), but the onKeyDown handler is empty. Consider if keyboard activation is needed.

  • Testing: No tests are shown in the PR. Should add:

    1. Unit tests for the selectAllMatches() method
    2. Integration tests for the button UI
    3. Tests for the button's enable/disable logic
  • Documentation: Should document the new button in VS Code's documentation.

Assessment

❌ Request changes

This PR is incomplete and cannot be merged in its current state.

Critical issues:

  1. Missing implementation: The PR adds the UI button and calls selectAllMatches(), but doesn't show the implementation of this method. Without this, the button will throw a runtime error when clicked.

  2. Missing action definition: The code references FIND_IDS.SelectAllMatchesAction for the keybinding label, but this action is not defined in the diff.

  3. Missing tests: No tests are provided for the new functionality.

Required changes before merging:

  1. Implement selectAllMatches() in the find controller with:

    • Clear documentation of what it does
    • Proper error handling
    • Edge case handling (no matches, large files, etc.)
  2. Define the action FIND_IDS.SelectAllMatchesAction with:

    • A unique ID
    • Keybinding configuration
    • Action handler
  3. Add comprehensive tests:

    • Unit tests for selectAllMatches()
    • UI tests for the button
    • Integration tests for the complete workflow
  4. Consider fixing the style issues:

    • Remove or implement the empty onKeyDown handler
    • Consider whether the direct DOM manipulation is necessary
    • Add comments explaining the button enable/disable logic

The PR shows good structure for the UI changes, but the core functionality is missing. Once the implementation is complete, this would be a valuable addition to VS Code's find widget.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor-find Editor find operations ux User experience issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "find all occurences" in the current file feature