| It's confusing you're replying to two different threads in this > For my own part I'm fine with falling back
> That's perfectly fine. That's for you. I want to open a huge XML file and edit it with autocomplete. I mean you could just say. I'm ok with Notepad. Ok. Sure. I'm not. > My editor uses just a plain array of lines represented as strings. Any naive approach is going to run into edge cases quickly[1]. Any more sophisticated approach is going to run into performance issues. > It will break horribly on huge files. I suspect it will break waaaay before that. Even using some language with greater complexity would cause issues. [1] For example using regex to color syntax. Reasonably fast yes, but fails in any moderately complex scenario. |
I get that, which is why I specified what it was I had replied to in order to clear it up.
> That's for you. I want to open a huge XML file and edit it with autocomplete.
That's fine. My editor is for me, not for you. To me, if you have to do bracket matching on a 2GB XML file an editor is the wrong tool. I'd work with that in a REPL. But that's me. You're totally free to pick your editor based on the need to handle 2GB files, just as I'm free not care one iota about opening 2GB files.
Hence my point that a lot of people don't seem to think about whether or not they actually need this. I decided I don't need it, and it let me simplify things a lot. It won't work for everyone, and that's fine.
> I mean you could just say. I'm ok with Notepad. Ok. Sure. I'm not.
Well, if I'd been ok with notepad, I'd have used notepad. I wrote my own editor because I'm not ok with Notepad. Or Emacs. The tradeoffs I care about are very different.
> Any naive approach is going to run into edge cases quickly[1]. Any more sophisticated approach is going to run into performance issues.
For large files, yes. It's more than fast enough to run just fine - even in pure Ruby - on files of the sizes I pointed out are the sizes I've decided I care about.
> [1] For example using regex to color syntax. Reasonably fast yes, but fails in any moderately complex scenario.
Which is why I'm using Rouge for the syntax-highlighting for my editor. It uses Regex for low level lexing where people choose to, but it supports state machines and multi-layered lexing or your own custom code. It supports all the languages I care about and dozens more just fine. My approach of caching the lexer state works just fine with Rouge and the approach I've outlined to e.g. parse my Ruby code with a precise Ruby mode, switch to a Markdown mode inside comment blocks, and feed the output of that into a layer that applies further custom rules based on my preferences. All without needing to build an AST for any of those.
> I suspect it will break waaaay before that. Even using some language with greater complexity would cause issues.
It handles every language supported by Rouge [1] just fine, and that's far more than I have need for.
[1] https://github.com/rouge-ruby/rouge/blob/master/docs/Languag...