{"action":"created","issue":{"url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/issues/4809","repository_url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus","labels_url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/issues/4809/labels{/name}","comments_url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/issues/4809/comments","events_url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/issues/4809/events","html_url":"https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4809","id":355578151,"node_id":"MDU6SXNzdWUzNTU1NzgxNTE=","number":4809,"title":"Macro problem: Search fails, rest of macro executes regardless","user":{"login":"Rekrullurker","id":23264794,"node_id":"MDQ6VXNlcjIzMjY0Nzk0","avatar_url":"https://avatars1.githubusercontent.com/u/23264794?v=4","gravatar_id":"","url":"https://api.github.com/users/Rekrullurker","html_url":"https://github.com/Rekrullurker","followers_url":"https://api.github.com/users/Rekrullurker/followers","following_url":"https://api.github.com/users/Rekrullurker/following{/other_user}","gists_url":"https://api.github.com/users/Rekrullurker/gists{/gist_id}","starred_url":"https://api.github.com/users/Rekrullurker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rekrullurker/subscriptions","organizations_url":"https://api.github.com/users/Rekrullurker/orgs","repos_url":"https://api.github.com/users/Rekrullurker/repos","events_url":"https://api.github.com/users/Rekrullurker/events{/privacy}","received_events_url":"https://api.github.com/users/Rekrullurker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-30T13:10:01Z","updated_at":"2018-09-01T06:51:53Z","closed_at":null,"author_association":"NONE","body":"### Description of the Issue\r\nIf you record a macro that contains a search, and that search fails to find the specified text, the rest of the macro will execute regardless. This makes it dangerous to use any macro that contains a search, especially if you use the option to repeat the macro to the end of the file.\r\n\r\n### Steps to Reproduce the Issue\r\n1. Make three lines that say: This is a XtestX more stuff\r\n2. Make three lines that say :This is a test more stuff\r\n3. Record a macro that searches for an X, moves to the right of the X and deletes from there to the beginning of the line. Then search for the X again, move to the left one space, delete it, then move to the start of the line and move down one line. Stop recording. Now run the macro to the end of the file.\r\n\r\n### Expected Behavior\r\nThe macro should only execute on the lines containing Xs and you should end up with;\r\n\r\ntest more stuff\r\ntest more stuff\r\ntest more stuff\r\nThis is a test more stuff\r\nThis is a test more stuff\r\nThis is a test more stuff\r\n\r\n### Actual Behavior\r\nInstead you get this;\r\n\r\ntest more stuff\r\ntest more stuff\r\ntest more stuffhis is a test more stuffhis is a test more stuffhis is a test more stuff\r\n\r\nThe macro works fine on the lines with Xs, but when it comes to the final three lines, the search fails so it just executes the rest of the macro anyway. Also, I'm not exactly clear on why the remaining lines ended up appended to the end of the third line, given that none of the deletes were at the end of a line and the backspace key was never used. Somehow it seems to have deleted the EOL characters.\r\n\r\nYou can create some very complex and powerful macros by using the search feature to locate parts of the file that you want to change, but it's pretty much rendered useless if it's just going to ignore the fact that the required text wasn't found.\r\n"},"comment":{"url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/issues/comments/417838008","html_url":"https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4809#issuecomment-417838008","issue_url":"https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/issues/4809","id":417838008,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzgzODAwOA==","user":{"login":"Rekrullurker","id":23264794,"node_id":"MDQ6VXNlcjIzMjY0Nzk0","avatar_url":"https://avatars1.githubusercontent.com/u/23264794?v=4","gravatar_id":"","url":"https://api.github.com/users/Rekrullurker","html_url":"https://github.com/Rekrullurker","followers_url":"https://api.github.com/users/Rekrullurker/followers","following_url":"https://api.github.com/users/Rekrullurker/following{/other_user}","gists_url":"https://api.github.com/users/Rekrullurker/gists{/gist_id}","starred_url":"https://api.github.com/users/Rekrullurker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rekrullurker/subscriptions","organizations_url":"https://api.github.com/users/Rekrullurker/orgs","repos_url":"https://api.github.com/users/Rekrullurker/repos","events_url":"https://api.github.com/users/Rekrullurker/events{/privacy}","received_events_url":"https://api.github.com/users/Rekrullurker/received_events","type":"User","site_admin":false},"created_at":"2018-09-01T06:51:53Z","updated_at":"2018-09-01T06:51:53Z","author_association":"NONE","body":"To clear up any possible confusion, I am **_NOT_** suggesting that the behavior of macros in regard to Search **_AND_** Replace be changed in any way. \"Search\" (technically \"Find\") is a completely separate menu item from \"Replace\", which initiates a Search **_AND_** Replace. I'm not trying to break everyone's existing macros. In the message below I am speaking exclusively about the stand-alone Find function which is invoked by CTRL-F. At no point should any of my comments be construed to apply to the Replace function which is invoked by pressing CTRL-H. As they are separate commands, a macro can easily differentiate between the two.\r\n\r\nWhen you use Find, it will reposition the cursor if the search text is found. In fact, that is the sole purpose of the Find command. There is no other reason to use it. If it is not found, the cursor doesn't move. In normal editing, Find is used to find parts of a document that you want to make changes to. If you search for something and it's not found, do you just go ahead and make the planned changes at the current cursor position regardless? Of course not. So why would you ever want a macro to behave this way?\r\n\r\nSince the Find command does nothing else by itself other than reposition the cursor if the search text is found, there is no conceivable reason anyone would ever use it in a macro. In other words, the sole purpose of the Find command is to conditionally reposition the cursor to a specific point in a file for the sole purpose of making changes to that specific part of the file.\r\n\r\nCan you give me an honest, actual example of a situation where you would use Find in a macro, but want the macro to execute regardless of whether the cursor was repositioned to another part of the file _OR_ whether it simply stayed at its current position? Both of these conditions would produce wildly different results and there would be no reason for a user to ever create a macro that doesn't work reliably in every situation. Conversely, can you give me an honest, actual example of how it would break something if the macro terminates early when a Find command fails?\r\n\r\nAgain, this isn't Replace I'm talking about, but the separate Find command which only repositions the cursor. If a user wants changes made at the current cursor position, they simply record them there. If they use the Find command, it means they want the cursor repositioned to a specific part of the file.\r\n\r\nFrankly, I never thought this would be a controversial idea. As it stands now, almost nobody would ever use Find in a macro unless they're 100% sure that at least the last line of the file contains the search text, otherwise it's going to blindly continue making changes to the file after the last instance of the search text is found. That severely limits the use of the Find command in Macros. Consequently, if nobody is using the Find command in macros, the change I suggested (stop execution of the macro if Find fails) would not affect anyone's existing macros. Even more so if it's a user-selectable option in prefs. \r\n\r\nIt shouldn't even break the scripts of people who have used Find in a macro. Because the only time it can be reliably used is if they know for a fact that the last line of the file contains their search text, the macro would still work just fine because the termination condition would never happen. It would reach the end of the file and stop, just as its supposed to. \r\n\r\nIn other words you couldn't use my example macro on this;\r\n\r\nThis is a XtestX more stuff\r\nThis is a XtestX more stuff\r\nThis is a test more stuff\r\nThis is a test more stuff\r\n\r\nBecause it will mangle the last two lines. You could only use it if the file looked like this;\r\n\r\nThis is a XtestX more stuff\r\nThis is a test more stuff\r\nThis is a test more stuff\r\nThis is a XtestX more stuff\r\n\r\nIt would skip over the middle lines, change the last line and exit normally. If you made macro execution conditional on the search text being found, the macro would still perform as expected because it would reach the end of the file without ever encountering the termination condition. However, it would also work just fine on my first example because it would change the first two lines, see that there are no more instances of the matching text and exit. Nothing gets broken because the very limited circumstance where search is used in a macro would already be situations where the user has made sure that the macro execution will only happen at specific points of the file. Making it conditional just takes that burden away from the user.\r\n\r\nMy comments about elitism were in regard to the fact that you would prefer users to learn a scripting language rather than being able to make full use of the much simpler macro recording facility already built into the program. While it's true you can't know what is or isn't easy for a person to learn, you can't deny that learning a scripting language is more complex than just recording a macro. Macros are intuitive enough that even novice users can understand the process. On the other hand, learning a scripting language can be a longer, more involved process. You can argue that the rewards are much greater, but most people don't want to learn a whole language just to be able to create macros, especially when the program already has its own macro recorder. Trust me, there are people for whom unpacking a Rar file requires itemized instructions and a video tutorial, every time they do it. Such people have no hope of learning scripting. \r\n\r\nTo be honest, I don't know any of those languages and don't really feel inclined to learn. I've written some Windows batch files and generally found it to be a colossal pain in the a** to include any kind of logic in them due to Microsoft's a**-backward variable handling where you have to jump through hoops to ensure that variables actually behave the way logic tells you that they should. Not to mention trying to keep straight all the various ways variables have to be referenced depending on what type of variable it is or what you're doing with it. I usually end up spending a minimum of half an hour trying to figure out what obscure condition is preventing my perfectly logical script from working properly. Sometime I have to ask in a forum so that someone can explain why you need to do something completely different because you used a different command. I've still never been able to get the errorlevel variable to work reliably inside a loop to determine if a command executed successfully or not. For that matter, I've never understood why you have to test the errorlevel command in reverse order from highest possible value to lowest, rather than it having an absolute value that you can test for. This kind of crap drives me nuts.\r\n\r\nAgain, I'm not trying to break anyone's existing scripts. The only conceivable situations where you would ever use Find in macro are situations where you have already manually made sure it's not going to blindly make changes to the file. Making the macro execution conditional just automates that process.\r\n"}}
{"actor":{"display_login":"Rekrullurker"}}