custom-editfield
custom-editfield copied to clipboard
Scrolling with Line Folding not working correctly
To reproduce:
Run the demo, fold the line containing "sub test". This folds away lines 8 to
171.
Now move the cursor to the bottom of the view, and then press the cursor down
key a few more times until the top line goes beyond the folded section.
At that point, the scroll position jumps instead of moving just one more line.
It appears that the issue lies inside CustomEditField.changeScrollValues(),
after the comment "//Cap values". Here, the variable "vertical" needs to be
adjusted to remove the folded lines, but this isn't happening.
Therefore, until this is fixed, Line Folding is fairly unusable.
Original issue reported on code.google.com by [email protected]
on 10 Sep 2013 at 10:46
Koen Van Hulle adds (via e-mail):
I have updated my code to the latest version of Custom Edit Field.
I encountered a problem with the foldings, which I couldn't get to work.
After a couple of hours debugging I found a workaround for me.
In my solution I start with an empty text field. This leads to an initial empty
value of the property mIndentationStateOut (Textline).
When loading a new XML in the edit field, the first line results also in an
empty mIndentationStateOut.
So the code stops checking the rest of the text.
Changing the method "UpdateIndentationState", by always setting the property
mChangedIndentState to true solved my issue.
I know this is not the most optimised way, but works for me.
==================
Sub UpdateIndentationState(definition as highlightdefinition, prevIndentationState as String, myText as String)
// TODO: Maybe optimize this so that it doesn't need to perform the Regex checks
// every time. E.g, if neither the mIndentationState nor the text changed, then
// there's no need to update.
// However, how to I tell if the text has changed? I shouldn't buffer each line here, that might
// be wasteful.
if mIndentationStateIn <> prevIndentationState then
mIndentationStateIn = prevIndentationState
mIndentationStateOut = prevIndentationState
mChangedIndentState = true
end
if me.length = 0 then
mIsBlkStart = false
mBlockIndent = 0
isBlockEnd = false
Return
end
// KVH commented out
'dim newState as String
'mBlockIndent = definition.isBlockStart(myText, mIndentationStateIn, newState)
'if newState <> mIndentationStateOut then
'mIndentationStateOut = newState
'mChangedIndentState = true
'end
'
'isBlockEnd = definition.isBlockEnd(myText, newState, newState)
'if newState <> mIndentationStateOut then
'mIndentationStateOut = newState
'mChangedIndentState = true
'end
// KVH- Force a change since the prev is not always working
dim newState as String
mBlockIndent = definition.isBlockStart(myText, mIndentationStateIn, newState)
isBlockEnd = definition.isBlockEnd(myText, newState, newState)
mIndentationStateOut = newState
mChangedIndentState = true
mIsBlkStart = mBlockIndent <> 0
End Sub
Original comment by [email protected]
on 18 Mar 2014 at 11:32
And more from Koen Van Hulle:
It seems to happen in certain circumstances.
Enclosed you find an example. Just click on the button "Load Sample XML".
Original comment by [email protected]
on 18 Mar 2014 at 11:32
Attachments: