micro-editor / micro-editor/micro
[Feature Request]: Allow multiline text in `TextEventReplace`
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
I am contributing to the Micro Language Server Protocol (mlsp) and have encountered an issue with the ExecuteTextEvent() method when handling TextEventReplace events. Currently, when deltas are created, it assumes that there are no newline characters within the text.
Is this an edge case that has not been considered, a bug, or an intended feature?
Please refer to line 130, where the same Y value is used for both Start and End:
You can find more details about the issue in these messages:
- https://github.com/Andriamanitra/mlsp/pull/23#discussion_r1912292428
- https://github.com/Andriamanitra/mlsp/pull/23#issuecomment-2590975293
We need to send the same changes to the LSP that Micro does. A possible solution on our side (similar to what needs to be done in Micro) could be the following:
-- treat as pseudocode
local splits = strings.Split(delta.Text)
local nsplits = #splits
local last_split_len = util.CharacterCountInString(splits[nsplits])
local char_begin = nsplits == 1 and delta.Start.X or 0
range["start"] = ...
range["end"] = {
line = delta.Start.Y + nsplits - 1,
character = char_begin + last_split_len
}
The LineArray functions remove and insert appear to handle newlines (likely for deleting multiline selections), but the upstream ExecuteTextEvent does not.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in internal/buffer/eventhandler.go around ExecuteTextEvent and the linked TextEventReplace handling at lines 125–135. Compare its newline behavior with the LineArray remove and insert functions, then verify that multiline changes produce the correct start and end positions for the LSP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100