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

Feature/clipboard sync #39

Merged
merged 9 commits into from
Oct 3, 2018
Merged

Feature/clipboard sync #39

merged 9 commits into from
Oct 3, 2018

Conversation

gtluszcz
Copy link
Member

@gtluszcz gtluszcz commented Oct 3, 2018

  • Replacing text is now made with synchronous clipboard replacements so that we can be sure that they are executed in order
  • Any error with clipboard will be indicated with notification (if possible)

@@ -2,18 +2,18 @@ const chars = require('./chars')
const NativeKeymap = require('native-keymap')
const _ = require('lodash')
const Notification = require('./Notification')
const clipboardy = require('clipboardy')
Copy link
Member

Choose a reason for hiding this comment

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

This dependency should be injected via the constructor to preserve testability.

@@ -188,12 +188,31 @@ class SnippetsManager {
}

replace(value) {
const clipboardContent = this.clipboard.readText()
try {
// 1. store old clipboard data
Copy link
Member

Choose a reason for hiding this comment

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

I don't think comments are necessary nor are adding any value. Let's write code that doesn't require comments ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, as you wish

this.keyboardSimulator.keyTap('v', 'command')
// 4. place stored data back in clipboard
setTimeout(() => clipboardy.writeSync(clipboardContent), 50)
return true
Copy link
Member

Choose a reason for hiding this comment

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

Returning a boolean may be a nice thing to do, but we are not using this returned information nowhere, so I don't see any value.

@DCzajkowski DCzajkowski merged commit a3b945f into master Oct 3, 2018
@DCzajkowski DCzajkowski deleted the feature/clipboard_sync branch October 3, 2018 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants