Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions PythonScript/python_tests/tests/test_NotepadWrapperTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,28 @@ def test_isAutoIndention(self):
''' '''
self.__test_invalid_parameter_passed(notepad.isAutoIndention)

def test_activateFile(self):
# Create and open two files
file1 = self.get_temp_filename()
file2 = self.get_temp_filename()
self.assertTrue(notepad.open(file1))
self.assertTrue(notepad.open(file2))

# open two temp files
notepad.new()
temp_1 = notepad.getCurrentFilename()
notepad.new()
temp_2 = notepad.getCurrentFilename()

self.assertTrue(notepad.activateFile(file1))
notepad.close()
self.assertTrue(notepad.activateFile(temp_1))
notepad.close()
self.assertTrue(notepad.activateFile(file2))
notepad.close()
self.assertTrue(notepad.activateFile(temp_2))
notepad.close()


suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTestCase)

Expand Down
9 changes: 8 additions & 1 deletion PythonScript/src/NotepadPlusWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,14 @@ bool NotepadPlusWrapper::activateFileString(boost::python::str filename)
{
notAllowedInScintillaCallback("activateFile() cannot be called in a synchronous editor callback. "
"Use an asynchronous callback, or avoid using activateFile() in the callback handler");
return handleFileNameToLongPath(NPPM_SWITCHTOFILE, filename);
bool res = handleFileNameToLongPath(NPPM_SWITCHTOFILE, filename);

if (!res) {
// issue 105
std::shared_ptr<TCHAR> tfileName = WcharMbcsConverter::char2tchar(boost::python::extract<const char*>(filename));
return static_cast<bool>(callNotepad(NPPM_SWITCHTOFILE, 0, reinterpret_cast<LPARAM>(tfileName.get())));
}
return res;
}

bool NotepadPlusWrapper::reloadFile(boost::python::str filename, bool alert)
Expand Down