Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

Conversation

@DaanDD
Copy link

@DaanDD DaanDD commented May 7, 2015

When text gets yanked, a short highlight appears as a small visual aid. Inspired by the Vintageous package from Sublime Text.

The only problem is that I could not figure out how to write specs for this feature. The specs in this example repo all seem to be using the Atom WorkspaceView, but the operators-spec.coffee seems to be using another way to initialise the editor. I also got quite some deprecation warnings while running the package specs.

So this feature should work, but there are no specs yet.

@bronson
Copy link
Contributor

bronson commented Jul 3, 2015

I love this.

Personally I'd like the highlight to be briefer. Might be worth making it a configurable setting? That would also offer and obvious way to turn it off.

2yy draws a box around the following line, making it look like only one line got yanked. Hitting p shows that the yank worked correctly and it's the highlight that was misleading.

Also yiw, yy, etc only show underline highlights, not boxes.

I notice that highlighting multiple-line selections can look weird:

bug3

If there's a way to make all of these boxes, so it's clear exactly what got yanked, I think this feature would be phenomenal.

@bronson
Copy link
Contributor

bronson commented Jul 3, 2015

Also, I have a similar testing issue in #723. (Well, I'm switching tabs so our tests are different, but being unable to figure out how to write UI tests is the same.)

Hoping @maxbrunsfeld has some time to offer a hint or two on the right way to do it.

@bronson
Copy link
Contributor

bronson commented Jul 4, 2015

@t9md did you mention on slack that you were having similar issues with quick-highlight? Any chance this is an an easy fix?

@t9md
Copy link
Contributor

t9md commented Jul 4, 2015

@bronson This is not same issue I talked on slack.
I think its because of decoration is line-wise?
Simply use style other than box I mean style without border.

@t9md
Copy link
Contributor

t9md commented Jul 4, 2015

My package clip-history do similar decoration to highlight pasted area. See gif anime of clip-history to check how its like.

@t9md
Copy link
Contributor

t9md commented Jul 4, 2015

I myself dont want to include these type of fancy feature to vim-mode core.
Maybe it could be disabled by configuration but it increase lines of code and config options.
Let vim-mode provide consistent event hook like onDidYank(callback) and callback passed range and text just yanked.
And user use these hook in external vim-mode add-on package.

@DaanDD
Copy link
Author

DaanDD commented Jul 4, 2015

@t9md: That seems like a good idea. I always found it really handy in Sublime Text's vim mode.

@bronson
Copy link
Contributor

bronson commented Jul 4, 2015

@t9md I had the same thought as you when I first looked at this patch. I only merged it just to be complete. I sure didn't want it.

... but I've grown to really like it. Maybe I'm losing my edge.

For example, I immediately see that I should have typed yaw instead of yiw. The days of navigating to the new buffer, pasting, seeing I got the yank wrong, navigating back to the original buffer, and trying again are gone! Immediate feedback is really nice.

In general, I agree that vim-mode should only include core vim stuff. But this is 3 lines of code... As long as it's turned off by default, I like the idea of including it.

A hook would be much better of course.

@bronson
Copy link
Contributor

bronson commented Jul 4, 2015

I removed this patch from vim-mode-next... A hook is the right way to do this.

@t9md
Copy link
Contributor

t9md commented Jul 4, 2015

I like this kind of immediate feedback decoration( I always try to implement this user assisting decoration in my packages).
But if the more we add vim-mode this kind of decoration, the more core code complicated.
And these preference is greatly vary from person to person, it sometimes become difficult to reach conclusion.
So hook is better for

  • keep core code simple
  • extensible for other package.

So I think we should open new Issue to discuss what type of hook(or event) is required.
For this topic, onDidYank(callback) and callback's argument should calback({text, range})
and its event is fired on y family operation.

@bronson
Copy link
Contributor

bronson commented Jul 4, 2015

And, to completely hijack this PR, I hope whoever investigates adding highlight hooks keeps #432 (highlighting find-previous and find-next jumps) in mind too.

@maxbrunsfeld
Copy link
Contributor

I like this feature too, and I'd be ok with adding it similarly to how it's currently implemented (as opposed to adding some kind of hook) but just without the css change. That way, users and theme authors could customize the look of the highlight just by tweaking CSS. We should also make the hard-coded timeout short so that the duration can be customized via css transitions.

There is some code in Atom core for doing things like this, but it is not yet documented. It's called 'flashing' a decoration. See this code in find-and-replace and these private methods on the Decoration class.

If anyone is interested in taking this further, I would suggest trying this:

for selection in @editor.getSelections()
  selection.setBufferRange(selection.getBufferRange(), flash: true)

You could also try flashing a custom decoration:

marker = @editor.markBufferRange(range)
decoration = @editor.decorateMarker(marker, type: 'highlight', class: 'yank-highlight')
decoration.flash('yank-flash', 50)

Then maybe tweaking the CSS to get the flash looking nice.

t9md added a commit to t9md/vim-mode that referenced this pull request Sep 2, 2015
Experimentally implemented for Yank, ToggleCase, Camelize, Dasherize,
UnderScore, ..
@lee-dohm
Copy link
Contributor

lee-dohm commented Apr 5, 2018

As stated in the README, this package is no longer maintained and is deprecated. We recommend that people use the vim-mode-plus package instead. Because of this, we are archiving this repository and closing all issues and pull requests. Thanks very much for your support and contributions!

@lee-dohm lee-dohm closed this Apr 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants