Prevent corruption possibility when using -p command line parameter
Fix #9142, close #9143
This commit is contained in:
parent
b54b8ee54f
commit
26428bd2ba
@ -5918,16 +5918,20 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ln != -1 || cpos != -1)
|
if (ln != -1 || cpos != -1)
|
||||||
{ //we have to move the cursor manually
|
{
|
||||||
|
//we have to move the cursor manually
|
||||||
int iView = currentView(); //store view since fileswitch can cause it to change
|
int iView = currentView(); //store view since fileswitch can cause it to change
|
||||||
switchToFile(bufID); //switch to the file. No deferred loading, but this way we can easily move the cursor to the right position
|
switchToFile(bufID); //switch to the file. No deferred loading, but this way we can easily move the cursor to the right position
|
||||||
|
|
||||||
if (cpos != -1)
|
if (cpos != -1)
|
||||||
{
|
{
|
||||||
|
// make sure not jumping into the middle of a multibyte character
|
||||||
|
// or into the middle of a CR/LF pair for Windows files
|
||||||
|
auto before = _pEditView->execute(SCI_POSITIONBEFORE, cpos);
|
||||||
|
cpos = static_cast<int>(_pEditView->execute(SCI_POSITIONAFTER, before));
|
||||||
_pEditView->execute(SCI_GOTOPOS, cpos);
|
_pEditView->execute(SCI_GOTOPOS, cpos);
|
||||||
}
|
}
|
||||||
else
|
else if (cn == -1)
|
||||||
if (cn == -1)
|
|
||||||
{
|
{
|
||||||
_pEditView->execute(SCI_GOTOLINE, ln-1);
|
_pEditView->execute(SCI_GOTOLINE, ln-1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user