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

Can I escape from a search without causing the macro recording to cancel? #31

Closed
bkinka8e opened this issue Jan 7, 2022 · 5 comments
Closed
Labels
question Further information is requested

Comments

@bkinka8e
Copy link

bkinka8e commented Jan 7, 2022

Thank you for creating this!
I often use macros to jump to a line containing some text and then do some action on that line (i.e. insert or delete text). However, when I Ctrl-f to search I cannot exit the search without either using the mouse which isn't recorded or hitting ESC which cancels the recording. Is there a workaround besides remapping this extensions default keys?

@tshino
Copy link
Owner

tshino commented Jan 8, 2022

Thank you for using this extension!

Yes, there are some ways to use the keyboard to exit the search input box and focus the editor.

  1. escape (closeFindWidget)
  2. ctrl+1 (or cmd+1 for Mac, workbench.action.focusFirstEditorGroup)

Either works for me (I'm using Windows).
Especially the second one is slightly useful since it keeps the input box visible so that I can continue the searching while editing.
So I often do the following steps. It's my recommendation.

  1. First, hit ctrl+f and type the word on the find input box.
  2. Hit ctrl+1 to focus back on the editor.
  3. Then, start recording.
  4. Any kind of editing with searching the word. Use f3 to find the next match.
  5. Stop recording.
  6. Playback!

However, I believe escape doesn't stop the recording with the default keybindings of this extension.
I'm afraid, did you add it yourself? or I might be misunderstanding what is going on or your question.

@tshino tshino added the question Further information is requested label Jan 8, 2022
@bkinka8e
Copy link
Author

Thanks for the suggestions. My attempted process on Windows was:

  1. Start recording
  2. ctrl-f
  3. Type in the search text (foobar)
  4. Press Esc keyboard button
  5. Do some editing (Home button, type /**, End button)
  6. Stop recording

I found that the @ext:tshino.kb-macro "Option1 (default)" bindings (Ctrl+Alt+R / Ctrl+Alt+P) this would cancel on the Esc step but a workaround I found was to change to the extension settings to use "Option2" (Ctrl+Shift+Alt+R / Ctrl+Shift+Alt+P) and Esc would work without cancelling the recording.

@tshino
Copy link
Owner

tshino commented Jan 10, 2022

Thanks for the details!
And it's good to hear that you found a workaround.

However, unfortunately, it didn't reproduce for me.

But I found a mistake in the process.

First of all (and as I noted in the README), step 3 (type in the search text) is not recorded. This is a limitation.

So even if the recording is not canceled and finishes properly, the recorded sequence would not include step 3, and it will contain only ctrl+f, escape, and editing. That is, open the input box and close it immediately and do some editing. This doesn't contain finding operations like f3. As a result, the playback will never move the cursor to the next match.

I think you were expecting to record the sequence like:

  1. Move the cursor to the next match of a word.
  2. Do some editing.

But your steps lack important step 1 of the above sequence.
Probably you had to hit enter on the search input box or hit f3, at least once in the steps.

I hope this helps.

@tshino
Copy link
Owner

tshino commented Jan 10, 2022

In addition,
I found that typing in the search input box while recording can result in unexpected cursor movement in the playback.
I think this is an issue that should be solved if possible.
I will create a new issue for that (typing in the search input box).

@bkinka8e
Copy link
Author

Sorry, my steps above were wrong. My final iteration I had copied the desired text to the clipboard so I used CTRL-V in the macro. Perhaps CTRL-V pasting didn't do anything during playback as you state but because the search box retains the last search text already it worked.

Thanks! I'll close this question as there is a workaround and the other issue you're creating can track further progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants