Comments (9)
I am still noticing this with current versions of AvalonEdit. I even turned off syntax highlighting and collapsing and even so, when I have a decent size block selection and try to type sometimes it takes a second per character.
Anyone have any ideas about fixes or optimizations? We unfortunately have a lot of people doing block selecting in our application...
from avalonedit.
I have noticed that some of the things mentioned in #9 do help. Turning off space showing does make it a little faster, but we need spaces shown, and also it really seems to happen more with block select.
from avalonedit.
@siegfriedpammer could this be fixed by using Document.BeginUpdate()
and Document.EndUpdate()
Or are you doing this already?
Could you point me at the relevant code, so that I can maybe try a PR ...
from avalonedit.
I would be happy to take a look at this as well if someone could point me to the relevant area in the code. We finally were able to update our VS version so I can actually give fixing this a try!
Our users are literally copy/pasting in/out of WordPad or NP++ in order to do block selection and typing because that's faster than trying to do it in the editor.
from avalonedit.
@goswinr I'm looking at the code and they do seem to have that area of code wrapped with using (textArea.Document.RunUpdate())
(so it does begin/end update), so that's not going to change anything.
I did some benchmark testing on my brand new and decently high-spec computer, timing this section of the code:
foreach (SelectionSegment lineSegment in this.Segments.Reverse()) {
ReplaceSingleLineText(textArea, lineSegment, newText, out insertionLength);
totalInsertionLength += insertionLength;
firstInsertionLength = insertionLength;
}
~100 lines took consistently 1.5-4 seconds
~500 lines took consistently almost a full minute
Looking a little deeper, the slowest part of ReplaceSingleLineText()
seems to be the Document.Insert()
and Document.Replace()
calls. To similar examples as before:
~180 lines too about 22ms per call
~540 lines took about 125ms per call
So first off, even without too many lines, that's quite slow for an action that's done for each line. 22ms * 180 lines is about 4 seconds just for the Insert()
calls. That means 4+ seconds per character press if you're trying to type in just 180 lines. With 540 lines it took over a full minute, again meaning that if you're trying to type in a block selection, you have to wait over a minute per key press.
I'm curious why the time in that function jumps so high. A 3x increase in lines consistently increased the call time by 5x, and that's nowhere near the max amount of lines our users would want to be able to select.
from avalonedit.
Just to add more as I debug, 90+% of the time is in TextArea.OnDocumentChanged()
and almost all of that is the selection.UpdateOnDocumentChange(e)
line. So it's the UpdateOnDocumentChange()
method of RectangularSelection
.
I'm not sure why the selection needs to be updated after each line of a change, and not just at the end. I.e. it seems like this update should be deferred by some mechanism if the change is triggered by a rectangular selection action.
Just for testing I commented out the changed event call (TextDocument.cs around line 877), it didn't seem to have any changes to behavior (visually things still seem to update) but the 500 line change takes 1-1.5 seconds per character, an order of magnitude difference. 100 lines was still the slightest bit jumpy, but markedly better at around 0.2-0.25 seconds for per character.
Also, just a note, the debugging output to time things that I have been putting in for testing is actually slowing stuff down. With no debugging output, and only timing the whole change, it takes on average about 0.1 seconds per character press for 500 lines. But for the purpose of debugging, the overhead added should be relatively constant (make 2 DateTimes, subtract them, and log it to the console).
from avalonedit.
Ugh, well the side effect of not calling Changed()
around line 877 is that it doesn't update the caret for normal typing.
from avalonedit.
@zaksmolen I could significantly improve the performance of typing in a rectangle selection by using TextArea.PreviewTextInput event , then doing the block edit myself via a Stringbuilder and then call doc.Replace only once. maybe something similar might help you. Changing the font or reducing the syntax highlighting might help too see #252
from avalonedit.
I believe I have finally resolved this in pull request 269.
from avalonedit.
Related Issues (20)
- Focus of Text Edit causes Scroll Viewer to Jump When Used Inside Container Panel HOT 3
- Editing in Multiline: tab added in the beginning instead of after the caret column position
- Add support to draw Custom Annotation on Vertical Scrollbar
- Autocompletion with indentation not working
- Ability to add spell checking HOT 1
- Memeory Issue: Two many objects cannot be collected by GC HOT 2
- How can I use the code completion by press Tab key other than input dot?
- The code completion effiencency can be improved
- .net 7 HOT 2
- duration of TextChange in a rectangular selection HOT 5
- Json.xshd fix HOT 2
- failed to parse html
- can i add this to winforms HOT 2
- Using VisualLineElementGenerator will cause the caret position wrong HOT 1
- Objects not being destroyed HOT 1
- Custom Kerning/Letter Spacing
- Group similar operations together in the undo stack
- The shortcut key Ctrl+K,Ctrl+D can format all the code.
- Rectangle selection rendering glitch with horizontal scrolling
- Editor Not Rendering HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalonedit.