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

Move last pasted item to the top of the drop down list #7

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

Conversation

hamparawa
Copy link

This PR attempts to fix the issue #5

textInserter.insert(activeEditor.selection.start, text); // Insert text from list

// Move the last pasted item to the top of the list.
clipboardArray.push(clipboardArray.splice(clipboardArray.indexOf(text), 1)[0]);

Choose a reason for hiding this comment

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

Don't we also need to remove the item from the array?

Copy link
Author

Choose a reason for hiding this comment

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

We are only moving the element to the top of the array. I don't understand what @heldersepu refers to. Can you be more specific please? Thanks,

Choose a reason for hiding this comment

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

@hamparawa I might be confused...
I don't see where you move clipboardArray.push only adds, right?

Choose a reason for hiding this comment

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

never mind I just noticed the nested splice...
it looks good

Copy link
Author

Choose a reason for hiding this comment

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

Push does the addition. But before that the array is spliced on the index of the text. (which effectively remove the element). This is a usual way of moving an element to the back of an array.

@hamparawa
Copy link
Author

hamparawa commented Jun 9, 2018

@aefernandes Is this project still being maintained?

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.

2 participants