cessen / ropey

A utf8 text rope for manipulating and editing large texts.
MIT License
1.04k stars 46 forks source link

function to remove newline between two lines #44

Closed crowlKats closed 2 years ago

crowlKats commented 3 years ago

It would be great if there was a simple way to remove the newline between two lines, turning it into one line

cessen commented 3 years ago

Ropey is intended to be lower level than that, and (intentionally) doesn't provide higher-level editing commands. The intention is that client code builds their own higher-level editing commands from the lower level methods provided by Ropey.

Having said that, I do think a function for getting the char index range of a line's line-ending might make sense. And that would make it trivial to do what you're asking: just query for the line-ending range, and then pass that to remove().

crowlKats commented 3 years ago

Ropey is intended to be lower level than that, and (intentionally) doesn't provide higher-level editing commands. The intention is that client code builds their own higher-level editing commands from the lower level methods provided by Ropey.

True, forgot that for a moment

Having said that, I do think a function for getting the char index range of a line's line-ending might make sense. And that would make it trivial to do what you're asking: just query for the line-ending range, and then pass that to remove().

that sounds perfect!

cessen commented 2 years ago

So, I've been sitting on this for a while. And that's mostly because I keep flipping back and forth between thinking this is a good idea or not.

And I think that's probably a sign that it doesn't, in fact, belong in Ropey. Thankfully, the code to implement it yourself is pretty straightforward.