Quick-close the search panel results


#1

Is there a way to quickly close the search results pane?

In particular, I would like a keyboard shortcut that:

  1. closes the search results tab, even when it is not focused;
  2. remove the pane where the tab was, if that pane has no other tabs; and
  3. does not do anything if no search results are being shown.

Does this exist by default or can it be easily added to the current config?

Cheers


#2

Add to your init.coffee (Atom > Open Your Init Script)

atom.commands.add 'atom-workspace', 'find-and-replace:close-results', ->
	itemUri = 'atom://find-and-replace/project-results'
	pane = atom.workspace.paneForUri(itemUri)
	pane?.destroyItem(pane.itemForUri(itemUri))

And your keymap.cson (Atom > Open Your Keymap)

'atom-workspace':
  'ctrl-whatever': 'find-and-replace:close-results'

On Windows/Linux, the menu items are under “File” instead of Atom (I think!)

The pane will be automatically removed if you have the ‘destroy empty panes’ setting checked.


#3

Wicked, thanks @postcasio:cake:

It’d be cool to not have to set Destroy Empty Panes, but that’s a tiny problem by comparison.


#4

Try this:

atom.commands.add 'atom-workspace', 'find-and-replace:close-results', ->
	itemUri = 'atom://find-and-replace/project-results'
	pane = atom.workspace.paneForUri(itemUri)
	pane?.destroyItem(pane.itemForUri(itemUri))
	unless pane?.getItems().length
		pane.destroy()

#5

:sun_with_face: @postcasio - that works, my sincere thanks!