--- a/eric7/QScintilla/Editor.py Tue Aug 24 17:20:58 2021 +0200 +++ b/eric7/QScintilla/Editor.py Tue Aug 24 18:04:32 2021 +0200 @@ -7,6 +7,7 @@ Module implementing the editor component of the eric IDE. """ +import bisect import collections import contextlib import difflib @@ -44,6 +45,8 @@ import UI.PixmapCache +from UI import PythonDisViewer + EditorAutoCompletionListID = 1 TemplateCompletionListID = 2 ReferencesListID = 3 @@ -2415,6 +2418,23 @@ @param temporary flag indicating a temporary breakpoint (boolean) """ if self.fileName and self.isPyFile(): + linestarts = PythonDisViewer.linestarts(self.text()) + if line not in linestarts: + if Preferences.getDebugger("IntelligentBreakpoints"): + # change line to the next one starting an instruction block + index = bisect.bisect(linestarts, line) + with contextlib.suppress(IndexError): + line = linestarts[index] + self.__toggleBreakpoint(line, temporary=temporary) + else: + EricMessageBox.warning( + self, + self.tr("Add Breakpoint"), + self.tr("No Python byte code will be created for the" + " selected line. No break point will be set!") + ) + return + self.breakpointModel.addBreakPoint( self.fileName, line, ('', temporary, True, 0)) self.breakpointToggled.emit(self)