Félix Paradis
Félix Paradis

Reputation: 6041

How to search the debug console in vscode?

This is currently a feature request, so I know the answer isn't straight forward, but I assume some clever people found clever workarounds for this.

One way is to copy/paste the output in some text editor, but ew.

Someone suggested redirecting the debug output to the terminal, which does have a search feature, sounds better.

So, the question is, how does one redirect the debug output to the terminal?

Unless, of course, you have an even better solution.

EDIT (from the GitHub thread)

You can use the property "console": "integratedTerminal" on the debug launch task to redirect the output to the terminal.

Upvotes: 28

Views: 29224

Answers (5)

starball
starball

Reputation: 50977

The Debug Console has a filter control since v1.49 which supports filtering things that match or don't match a pattern (prefix with ! to use "exclude" mode). You can focus this control with ctrl/cmd+f when the Debug Console is focused.

It also has a find widget since v1.93 (see also #225093). The control can be focused with ctrl/cmd+alt/opt+f when the Debug Console is focused. In v1.93, the find widget only searches inputs in the Debug Console. I think in 1.94 it will also search outputs (see #225417).

Upvotes: 2

VonC
VonC

Reputation: 1326616

Since August 2020 and VSCode 1.49, the Debug Console does support filtering:

Debug Console filter

The Debug Console now supports filtering, making it easier for users to find the output they are looking for, or to hide irrelevant logging output.

The filter also supports exclude patterns (for example, patterns starting with an exclamation mark !).
The filter only applies to program output, but not to evaluations run by a user.

Like other input boxes in VS Code, you can use the up and down arrow keys to navigate between old filter inputs.

In the short video below, the output is filtered to entries that include the text 'http', do not include the text 'http' (using the filter !http), and then include the word 'Severity':

Debug Console filtering -- https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_49/filter.gif

(Click on the picture to enlarge. Look for the filter at the top right section of the animation)


And with the upcoming Sept. 2020 VSCode 1.50, you know where you are in your search:

Since last milestone the Debug Console supports filtering, making it easier for users to find the output they are looking for, or to hide irrelevant logging output.

Now we have added a badge to make it clear how many items are filtered away.

Debug console badge -- https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_50/debug-console-badge.png


Nov. 2023, Sattar Hummatli adds in the comments:

Go to root folder of project and type "flutter logs"


As noted by Troopers in the comments:

You can combine filters (AND) using a comma:

!native, !result

Upvotes: 14

Sattar Hummatli
Sattar Hummatli

Reputation: 1408

To have search instead of filter you need to go to root folder of project and type flutter logs

Upvotes: -1

Saik0s
Saik0s

Reputation: 446

I recently stumbled upon the same issue and managed to find a workaround that did the trick for me. I thought I'd share it here in case it could help you or anyone else who's grappling with the same problem.

  1. Navigate to the Keyboard Shortcuts section in VSCode Code > Settings > Keyboard Shortcuts.

  2. Use the search bar to look for cmd+f.

  3. After locating the command, check the When column, in my case it indicated that Find should always trigger if editor is open, even if not in focus editorFocus || editorIsOpen.

  4. To make the command functional even when the terminal is in focus, modify the When value to editorFocus || editorIsOpen && !terminalFocus so that it checks if terminal is not in focus when cmd+F pressed.

enter image description here

Upvotes: 1

Félix Paradis
Félix Paradis

Reputation: 6041

Looks like this answer is now outdated, see this other answer instead.


A type-to-filter functionality has been added. To use it:

  1. Give focus to the debug console (By clicking it, for instance.)
  2. Press cmd + F / ctrl + F
  3. Start typing

You will see what you type in the upper right corner of the debug console.

The little text box that appears top right corner of the debug console

You can then "enable filter on type" (the 3 lines left of the 'x') and only matching lines will show in the debug console. Press Escape to clear the search.

So it's not exactly the search feature OP was looking for, plus you can't type spaces, but it's the best built in tool for now (July 2019).

Upvotes: 31

Related Questions