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

vim-highlightedyank implementation #3142

Closed
AckmanDESU opened this issue Oct 16, 2018 · 4 comments
Closed

vim-highlightedyank implementation #3142

AckmanDESU opened this issue Oct 16, 2018 · 4 comments

Comments

@AckmanDESU
Copy link

Is your feature request related to a problem? Please describe.
I'm sometimes confused by yanks not registering or not yanking the correct thing. Adding visual feedback after a yank would solve this issue.

Describe the solution you'd like
Similar to vim-highlightedyank, a short duration highlight would be enough. This should work for all possible motions.

Describe alternatives you've considered
I've honestly spent the last 3 hours looking at documentation and code for VSCode and this extension but sadly I'm a newbie at programming. It seems easy on paper but there's far too many things I don't fully understand. I'd implement this myself if I could get a couple of pointers honestly.

@AckmanDESU
Copy link
Author

AckmanDESU commented Oct 16, 2018

This here is what I want. I just can't make it work 100%.

@AckmanDESU
Copy link
Author

diff --git a/src/actions/operator.ts b/src/actions/operator.ts
index 2548a90d..38f0afc9 100644
--- a/src/actions/operator.ts
+++ b/src/actions/operator.ts
@@ -11,6 +11,9 @@ import { BaseAction, RegisterAction } from './base';
 import { CommandNumber } from './commands/actions';
 import { TextObjectMovement } from './textobject';
 
+import { SearchDirection, SearchState } from '../state/searchState';
+import { Decoration } from '../configuration/decoration';
+
 export class BaseOperator extends BaseAction {
   constructor(multicursorIndex?: number) {
     super();
@@ -267,6 +270,18 @@ export class YankOperator extends BaseOperator {
 
     let text = TextEditor.getText(new vscode.Range(start, end));
 
+    vimState.globalState.searchState = new SearchState(
+      SearchDirection.Forward,
+      vimState.cursorPosition,
+      text,
+      undefined,
+      vimState.currentMode
+    );
+
+    setTimeout(() => {
+      vimState.globalState.searchState = undefined;
+    }, 10);
+
     // If we selected the newline character, add it as well.
     if (
       vimState.currentMode === ModeName.Visual &&

This is how what I showed in the video was done, by the way. Forcing a search is not the right way I'm sure... I was just messing around.

@jpoon
Copy link
Member

jpoon commented Oct 19, 2018

Current PR for this: #3129

@J-Fields
Copy link
Member

Fixed with #3593

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

No branches or pull requests

3 participants