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

Don't crash Notepad++ when running plugin commands with multiple selections #198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

molsonkiko
Copy link

@molsonkiko molsonkiko commented Sep 14, 2024

FIX

This would fix #197 .

Previously, running any plugin command other than Settings or About would cause Notepad++ to crash if the user had multiple selections. This commit would fix this issue by, whenever they use a single-selection-only command, informing the user and bailing out early if they have multiple selections.

You may not agree with this specific approach to fixing this bug, but I would argue that an easily reproduced issue that is guaranteed to cause a Notepad++ crash should be treated with the highest urgency. I won't be offended if you reject this PR, so long as you promptly fix the issue it is intended to address.

HOW THE FIX WORKS

Quite simple; before running any action that involves parsing JSON (these all seem to call the ConstructJsonDlg method), we check if the user has multiple selections in the current document. If they do, we show them a message box saying that JSON Viewer doesn't support multiple selections, and return early.

If the user has only one selection, we run the plugin command normally.

NEW AFTER-BUILD ACTION

Add a new after-build action to NPPJSONViewer.vcxproj that creates an NPPJSONViewer plugin directory (if one doesn't already exist) in the appropriate Notepad++ installation (%ProgramFiles%\Notepad++ for an x64 build or %ProgramFiles(x86)%\Notepad++ for a Win32 build) and then copies the NPPJSONViewer.dll that you just built into that plugin folder.

I also tried to add another action that would run that Notepad++ installation afterwards, but I couldn't figure out how to do that.

SinghRajenM and others added 2 commits September 12, 2024 22:27
FIX:
Previously, running any plugin command other than Settings or About
    would cause Notepad++ to crash if the user had multiple selections.
    This commit would fix this issue by, whenever they use a single-selection-only command,
    informing the user and bailing out early if they have multiple selections.
FEAT:
Add a new after-build to NPPJSONViewer.vcxproj
    that creates an NPPJSONViewer plugin directory (if one doesn't already exist)
    in the appropriate Notepad++ installation (%ProgramFiles%\Notepad++ for an x64 build or %ProgramFiles(x86)%\Notepad++ for a Win32 build)
    and then copies the NPPJSONViewer.dll that you just built into that plugin folder.
I also tried to add another action that would run that Notepad++ installation afterwards,
    but I couldn't figure out how to do that.
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

Successfully merging this pull request may close these issues.

BUG: Performing plugin commands when the user has multiple selections caused Notepad++ to crash
2 participants