Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Allow Project Find Results to be copied to clipboard #764

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liuderchi
Copy link

@liuderchi liuderchi commented Aug 4, 2016

Related issue #416.
copy result of Project-Find to clipboard.

changes:

  1. add Util.copySearchResultFromPane() to copy text from search result pane
  2. add context menu item supporting right-click on project-find result page.
    (of course can use it via command-palette)

demo:
demo

NOTE: hidden entries under collapsed item are not copied to clipboard so that result is consistent with view.

@@ -183,6 +186,10 @@ class ProjectFindView extends View
@updateReplaceAllButtonEnablement(@model.getResultsSummary())
@handleEventsForReplace()

copySearchResultFromPane: ->
atom.clipboard.write(Util.parseSearchResult())
atom.notifications.addInfo('Search results are copied to clipboard')
Copy link
Contributor

Choose a reason for hiding this comment

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

Search results have been copied to clipboard

@50Wliu
Copy link
Contributor

50Wliu commented Aug 4, 2016

Very nice! Left you a few comments to resolve the lint errors.

@@ -146,6 +146,9 @@ class ProjectFindView extends View
'project-find:toggle-whole-word-option': => @toggleWholeWordOption()
'project-find:replace-all': => @replaceAll()

@subscriptions.add atom.commands.add 'div.preview-pane',
'project-find:copy-search-result': @copySearchResultFromPane
Copy link
Contributor

Choose a reason for hiding this comment

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

-results

Copy link
Author

Choose a reason for hiding this comment

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

I will update this in menus/find-and-replace.cson also.

@liuderchi
Copy link
Author

@50Wliu is there anything else I need to change? 😃

@50Wliu
Copy link
Contributor

50Wliu commented Oct 9, 2016

/cc @maxbrunsfeld

preview = $('span.preview', this).text()
searchResult.push '\t' + lineNumber + '\t' + preview
searchResult.push ''
searchResult.join('\n')
Copy link

Choose a reason for hiding this comment

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

Above part could be rewritten with plain DOM API to remove the space-pen dependency with minimal effort. Might help with getting this merged.

Copy link
Author

@liuderchi liuderchi Nov 27, 2016

Choose a reason for hiding this comment

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

@jerone that's good Idea and I will work on it.

@liuderchi
Copy link
Author

liuderchi commented Nov 27, 2016

@50Wliu how do think about the format of copied content?

Also I guess spec for this feature is a nice-to-have.

@liuderchi
Copy link
Author

liuderchi commented Feb 4, 2017

@50Wliu @jerone this PR now is

  • using DOM API without space-pen dependency
  • having corresponding spec

Anything else I can help?

@50Wliu
Copy link
Contributor

50Wliu commented Feb 5, 2017

I don't feel qualified to review this PR, but I'll try to get someone else to take a look at it.

@dezman
Copy link

dezman commented Mar 15, 2017

Who has context top review this? Would love this feature.

@liuderchi liuderchi force-pushed the copy_porject_search_result branch from a6c9eb9 to 8aa9601 Compare May 2, 2017 15:42
- add parseSearchResult() in util.coffee with DOM api
- add copySearchResultFromPane() in project-find-view.js
- add spec in project-find-view-spec.js
- add context-menu item
@liuderchi liuderchi force-pushed the copy_porject_search_result branch from 8aa9601 to 4841893 Compare May 3, 2017 14:15
@liuderchi
Copy link
Author

liuderchi commented May 4, 2017

currently project-find results page shows only visible items in DOM tree.
(when you scroll down, first DOM node disappears in the top, new one comes in the bottom.)

so this PR cannot parse all search results from DOM as long as search results exceed the page view.

@liuderchi
Copy link
Author

@steveoh too bad this PR does not fit the view in current version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants