BUGFIX: Fixed crash on some include file cases.
Reported by ETH students last year: if you include a file, where the file has an error in a line with a number higher than the original, the Python code crashes. This is a *patch* only because the real underlying problem is that error reporting does not take include commands into account, and does not propagate any file names.
This commit is contained in:
parent
9605d5e772
commit
feb3827ba1
@ -158,12 +158,26 @@ class EditorStc(Editor):
|
|||||||
def SetText(self, txt):
|
def SetText(self, txt):
|
||||||
self.control.SetText(txt)
|
self.control.SetText(txt)
|
||||||
|
|
||||||
|
def GetLineCount(self):
|
||||||
|
""" Currently rather stupid, can probably be done more
|
||||||
|
efficiently through some Scintilla function. """
|
||||||
|
txt = self.GetText().splitlines()
|
||||||
|
return len(txt)
|
||||||
|
|
||||||
def SetErrorLine(self,line):
|
def SetErrorLine(self,line):
|
||||||
line = line - 1 # Start at 0 in stc, but on screen count is 1
|
"""
|
||||||
pos = self.control.GetLineIndentPosition(line)
|
Currently this is BROKEN for include commands, as no file names
|
||||||
last = self.control.GetLineEndPosition(line)
|
are propagated. To minize the damage, we at least don't try to
|
||||||
self.control.StartStyling(pos,31)
|
highlight non-existing names. In the long run of course
|
||||||
self.control.SetStyling(last-pos,self.errorstyle)
|
propagation is the only way to handle this.
|
||||||
|
"""
|
||||||
|
if line <= self.GetLineCount():
|
||||||
|
if line > 0:
|
||||||
|
line = line - 1 # Start at 0 in stc, but on screen count is 1
|
||||||
|
pos = self.control.GetLineIndentPosition(line)
|
||||||
|
last = self.control.GetLineEndPosition(line)
|
||||||
|
self.control.StartStyling(pos,31)
|
||||||
|
self.control.SetStyling(last-pos,self.errorstyle)
|
||||||
|
|
||||||
def ClearErrors(self):
|
def ClearErrors(self):
|
||||||
self.control.ClearDocumentStyle()
|
self.control.ClearDocumentStyle()
|
||||||
|
Loading…
Reference in New Issue
Block a user