You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
notepad.activateBufferID can activate incorrect cloned document #382
The NPPM_GETPOSFROMBUFFERID message takes two arguments, but the PS code only supplies one. The second argument should be supplied and should be the currently active view number.
lParam [in]
int priorityView, which must be either 0 (main view) or 1 (secondary view). It will search the chosen view first, but if the given bufferID cannot be found in the chosen view, the other view will also be searched.
Return value:
Returns -1 if bufferID doesn’t exist, else returns the encoded viewIndex and docIndex.
this should also work without the view. But at least the return value of -1 is not checked.
@alankilborn I'm not sure if the bufferID is the same in both views. If yes, then the search order would be set by view parameter which is indeed the default value from callNotepad and 0 aka main view.
This would require to add getCurrentView() to the method and provide the result as lparam to NPPM_GETPOSFROMBUFFERID
Activity
chcg commentedon Apr 7, 2025
@alankilborn According to docu:
this should also work without the view. But at least the return value of -1 is not checked.
alankilborn commentedon Apr 7, 2025
@chcg
I didn’t check, but it could be that ‘callNotepad’ supplies a 2nd argument of zero, causing the bug in the scenario I outlined.
alankilborn commentedon Apr 8, 2025
Confirmed:
callNotepad uses a default argument for
lParamand the default argument is zero.Thus, that's the bug. @chcg Do you agree?
Side note:
If a
-1results, there is nothing to do anyway, as there is no following code in the function.chcg commentedon Apr 8, 2025
@alankilborn I'm not sure if the bufferID is the same in both views. If yes, then the search order would be set by view parameter which is indeed the default value from
callNotepadand 0 aka main view.This would require to add getCurrentView() to the method and provide the result as lparam to NPPM_GETPOSFROMBUFFERID
See NPPM_GETPOSFROMBUFFERID:
https://github.com/notepad-plus-plus/notepad-plus-plus/blob/5c1813185aa111d6247de39e3d7049ebef0960e0/PowerEditor/src/NppBigSwitch.cpp#L2280
alankilborn commentedon Apr 8, 2025
It is.
Oh, I see, you mean the return value from the NPPM_GETPOSFROMBUFFERID, not from NPPM_ACTIVATEDOC, like I first thought...
fix bruderstein#382
alankilborn commentedon Jul 18, 2025
Verified as fixed in PS 3.0.23 using Notepad++ 8.8.3.
alankilborn commentedon Jul 18, 2025
Just as a reference, this was also discussed on the Community, starting here: https://community.notepad-plus-plus.org/post/100707