t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Search API command doesn't give indication of success #1068

Open calebmeyer opened 6 years ago

calebmeyer commented 6 years ago
debug info ```json { "atom": "1.26.1", "platform": "win32", "release": "10.0.16299", "vmpVersion": "1.32.0", "vmpConfig": { "automaticallyEscapeInsertModeOnActivePaneItemChange": true, "keymapBackslashToInnerCommentOrParagraphWhenToggleLineCommentsIsPending": true, "keymapCCToChangeInnerSmartWord": true, "keymapPToPutWithAutoIndent": true, "keymapUnderscoreToReplaceWithRegister": true, "keymapYToYankToLastCharacterOfLine": true, "showHoverSearchCounter": true, "statusBarModeStringStyle": "long", "useSmartcaseForSearch": true, "useSmartcaseForSearchCurrentWord": true, "wrapLeftRightMotion": true, "blackholeRegisteredOperators": [], "startInInsertModeScopes": [], "charactersToAddSpaceOnSurround": [], "highlightSearchExcludeScopes": [], "flashOnOperateBlacklist": [] } } ```

Read and check all "Check list" bellow.

Check list

You have to check all before open issue.

What

I would like for the search commands to globally store or return some programmatic indication whether the search found any results.

I am aware that searching gives auditory (beep) feedback and visual (flash) feedback, but I don't know that either of those have happened when I dispatch a search command.

Why

I'm maintaining a simplified macro system for vim mode plus over at https://github.com/calebmeyer/vim-mode-plus-macros . This is one of the pieces I think I need to properly support https://github.com/calebmeyer/vim-mode-plus-macros/issues/4 . If I know whether a search is failed, I can stop processing a macro once I hit a search failure.

Versions

$ apm --version
apm  1.19.0
npm  3.10.10
node 6.9.5 x64
atom 1.26.1
python 3.6.5
git 2.16.2.windows.1
visual studio

vim-mode-plus 1.32.0

Windows 10 Fall Creators' Update (10.0.16299)
calebmeyer commented 6 years ago

The code I'm using to test this is on my fix-search branch on the vim-mode-plus-macros repo. When I run a macro that includes a search, dispatching the search commands gives me a promise, which is resolved as [undefined] (an array containing one element, undefined).

The buffer I'm testing on just contains two lines, each with the word "hello" image

Here's the console log statement

Here's a successful search (found the h character): image

And here's a failed search (did not find z): image

t9md commented 6 years ago

Sorry for my late response. Before going to implement your request, I want clarify basic understanding.

Could you replay macro which include search(/) as long as search can find match? I didn't check detail of your packages, but implementing macro on Atom editor is not easy in some situation. When you search(/) keyword normally, activeElement become search's mini-editor then your keystrokes would be sent to that activeElement. When you replay keystroke by dispatch, you need to keep track of shift of activeElement which might or might not be introduced by each keystroke.

Btw what is "Search API command" you are mentioning?

calebmeyer commented 6 years ago

Search API command is the result of dispatching core:confirm against the mini-editor. I believe it runs search internally.

t9md commented 6 years ago

Ok, its not search API, it’s just atom’s api yo dispatch command programatically.

So, to simplify the issue are you saying you want the promise retuned by core:confirm to the search-mini-editor return different value depending of result, which is curtently same undefined valued arrray.

Am I understanding your request correctly?

calebmeyer commented 6 years ago

Yes. I would either like to be able to determine the success/failure of the search as the result of dispatching core:confirm, or I would like another way to determine it.

Vim-mode-plus knows whether the last search command succeeded or failed, since it has search-state and it is giving me a beep/flash. I just want a way to find that out from my package.