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

[BUG] Macros mangle my files #15110

Open
1 task done
SDESkowronski opened this issue May 8, 2024 · 3 comments
Open
1 task done

[BUG] Macros mangle my files #15110

SDESkowronski opened this issue May 8, 2024 · 3 comments

Comments

@SDESkowronski
Copy link

SDESkowronski commented May 8, 2024

Notepad.Macro.Bug.Inserting.Extra.Lines.mp4

Is there an existing issue for this?

  • I have searched the existing issues

Description of the Issue

See attached video showing the bug. The point of counting the usage of the macro in the video that I forgot to mention in the video is that is the number of unexpected new lines that Notepad++ inserts into the code.

I use macros all the time to transform software code files, probably 2 months ago was the last time I used it until today. With this latest update, it is mangling my code text with extra new line characters in random places. I'm not really sure how to describe what it is doing because it is so random and so different from past experiences I can only say it must be a bug.

ALSO it is intermittent. I've had it happen on the first file I used the macro on. I've also had it happen after 4-8 files with no issues, then the issue comes up and Notepad++ starts flaking out. If I don't close and restart Notepad++, after sometime Notepad++ will crash.

The only thing different that I am doing than I've done in the past is that I turned on "enable virtual space", which was necessary to accomplish the transformations I was doing.
Preferences -> Editing 1 -> Enable Virtual Space

I am not using extra plugins (I had one installed "SearchPlus", but later I removed it and re-did the test and it reproduced without it). Otherwise I am just using what comes with Notepad++ when I download it.

Steps To Reproduce

For the video I used the Notepad++ source code that I got from GitHub. But for my original issue...

The purpose of this macro is to add a log entry before calling an API in Python Pytest code. The end result would look like the following...
# Some comment or other line of code up here.
Test.log('PLACEHOLDER - There should be a meaningful log entry here.')
initial_count = test_user.query("countSomething", {"version": version})
So this macro adds the "Test.log" line to the code directly above the query call.

  1. Preferences -> Editing 1 -> Enable Virtual Space
  2. Search all files in a path for a line with ".query(" in it.
  3. Go to that line in the file and run the following macro as many times as needed for the file. Manually verify at each new found search location that I needed to add that line of logging code.
  4. Save the file once all logging lines have been added
  5. Repeat at step 3 until all files have been processed.

The macro:
Home
Ctrl+Alt+Enter
Down Arrow
Up Arrow
Ctrl+V
F3
F3

Current Behavior

    // Some comment or other line of code up here.
    Test.log('PLACEHOLDER - There should be a meaningful log entry here.')
    initial_count = test_user.query("countSomething", {"version": version})

In a few cases it was worse as it added line breaks in multiple spots of a data structure.

Expected Behavior

    # Some comment or other line of code up here.
    Test.log('PLACEHOLDER - There should be a meaningful log entry here.')
    initial_count = test_user.query("countSomething", {"version": version})

Debug Information

Notepad++ v8.6.5   (64-bit)
Build time : Mar 29 2024 - 17:04:43
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
OS Name : Windows 10 Enterprise (64-bit
OS Version : 22H2
OS Build : 19045.4291
Current ANSI codepage : 1252
Plugins : 
    mimeTools (3.1)
    NppConverter (4.6)
    NppExport (0.4)
    SearchPlus (0.1.6)

Anything else?

No response

@alankilborn
Copy link
Contributor

alankilborn commented May 9, 2024

The macro seems to work ok for me.


Some comments on the macro that probably don't matter:

  • Home is context-dependent. Meaning, it will do different things depending upon caret position and underlying text when it is executed. Better is to do the sequence Alt+Home to go to column 1 absolutely, followed by Home to go to the first non-whitespace column on the current line (if that is truly your intention)
  • I don't really see a point to the Down Arrow then Up Arrow sequence (maybe it is important but to me seems like it could be dropped

You make a point of emphasizing enabling of virtual space. I tried it with your macro in various conditions and it didn't make a difference, but, have you tried disabling virtual space and seeing if it changes the macro operation for you?


What is the "SearchPlus" plugin? -- I've never encountered that one.

@SDESkowronski
Copy link
Author

SDESkowronski commented May 9, 2024

Thanks @alankilborn for trying to reproduce. I added a video of the reproduction using Notepad++ source code. Luckily I was able to reproduce it on the very first file I attempted to alter! I also updated the original report with the new understanding of the bug that I had after intentionally trying to reproduce it. I also removed that "SearchPlus" plugin, which made no difference. In the video I addressed your other questions.

@SDESkowronski
Copy link
Author

UPADATE #2:
This bug reproduces in v8.4.9 64 bit as well.

I had to do the exact same transformation to another project, so I installed an older version hoping the issue would go away, but it didn't. This really puzzles me...how come I've never encountered this issue in the past? I've been using Notepad++ for a very long time, I've never ran into this trouble. Why now? Could some OS change be affecting it?

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

2 participants