<p>This may be beyond the scope of Geany, but it looks like <code>vi</code> was designed to be efficient for use on a 300 baud modem, so it loads lines on demand. It may be worth looking into the source code, yet is a bit hackish.</p>
<blockquote>
<p>"Author of Scintilla here. Scintilla does not use a list of lines. The text is stored in a gap buffer (the substance field in the code shown), like EMACS. Line start positions (added by the InsertLine method) are also stored in a gap buffer but with a 'step' which enables modifications in close proximity to affect few elements."</p>
</blockquote>
<blockquote>
<p>What is inefficient about this is if you have a giant line, Scintilla will slow right down, because it goes through every character in the block to determine where new lines are. So if you copy & paste from an external source, you could potentially see a slow down. As a code editor though, this should rarely be a problem. Like GtkTextView, Scintilla's Editor interface is lacking key binding overlays to allow users to use Vi or Emacs keybindings out of the box.</p>
</blockquote>
<p><a href="https://ecc-comp.blogspot.com/2015/05/a-brief-glance-at-how-5-text-editors.html">https://ecc-comp.blogspot.com/2015/05/a-brief-glance-at-how-5-text-editors.html</a></p>
<p>From what I've read, the main problem has to do with dynamic line sizes, Geany/Scintilla doesn't know where the next line will end so it has to scan every character to keep its loaded undo buffer. I'm not sure why you guys reported that it consumes twice the size of the file size. It sounds like it shouldn't, but it I don't have time to test it at the moment.</p>
<p>Not sure if it would be possible to improve geany to using a static line size setting that eliminates the scanning and possibly the dynamic undo buffer to ensure memory is not allocated if its not necessary.</p>
<p>It would also be nice to warn the user if Geany is in danger of running out of memory. Then a user could commit changes as necessary and reset the undo buffer while not continuing to consume more memory.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1569#issuecomment-320127293">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJz1VbeUEX0-KD-ngxQHdraQv5Lt8ks5sUmq4gaJpZM4OtGp5">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJxUqbrrNL8BG6u7yS5QkcZ9RM-2Fks5sUmq4gaJpZM4OtGp5.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/1569#issuecomment-320127293"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@AdamDanischewski in #1569: This may be beyond the scope of Geany, but it looks like `vi` was designed to be efficient for use on a 300 baud modem, so it loads lines on demand. It may be worth looking into the source code, yet is a bit hackish.  \r\n\r\n\u003e \"Author of Scintilla here. Scintilla does not use a list of lines. The text is stored in a gap buffer (the substance field in the code shown), like EMACS. Line start positions (added by the InsertLine method) are also stored in a gap buffer but with a 'step' which enables modifications in close proximity to affect few elements.\"\r\n\r\n\u003e What is inefficient about this is if you have a giant line, Scintilla will slow right down, because it goes through every character in the block to determine where new lines are. So if you copy \u0026 paste from an external source, you could potentially see a slow down. As a code editor though, this should rarely be a problem. Like GtkTextView, Scintilla's Editor interface is lacking key binding overlays to allow users to use Vi or Emacs keybindings out of the box.\r\n\r\nhttps://ecc-comp.blogspot.com/2015/05/a-brief-glance-at-how-5-text-editors.html\r\n\r\nFrom what I've read, the main problem has to do with dynamic line sizes, Geany/Scintilla doesn't know where the next line will end so it has to scan every character to keep its loaded undo buffer. I'm not sure why you guys reported that it consumes twice the size of the file size. It sounds like it shouldn't, but it I don't have time to test it at the moment. \r\n\r\nNot sure if it would be possible to improve geany to using a static line size setting that eliminates the scanning and possibly the dynamic undo buffer to ensure memory is not allocated if its not necessary. \r\n\r\nIt would also be nice to warn the user if Geany is in danger of running out of memory. Then a user could commit changes as necessary and reset the undo buffer while not continuing to consume more memory. "}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1569#issuecomment-320127293"}}}</script>