micro-plugin-lsp icon indicating copy to clipboard operation
micro-plugin-lsp copied to clipboard

Big file is freeze the micro for a while

Open 1buran opened this issue 1 year ago • 1 comments

Description of the problem or steps to reproduce

It seems like the micro editor performance issue: "re-analyze" (re apply the color scheme or something else what it does) whole file on every char input.

It freezes for a while and then hangs again on every char input, the htop shows big CPU consumption in that time (see attached screenshots) :(

Steps to reproduce:

  1. Open a big file. e.g. 26k+ lines of php code
  2. Try to add something - the micro will be freezed on every char entered

Specifications

Micro Commit hash: 68d88b57 (Version: 2.0.13) OS: Manjaro Linux 23.1.4 (Arch Linux) Terminal: kitty Lsp version: 0.6.2

Editing: image

First opening: image

1buran avatar May 01 '24 09:05 1buran

This is likely because of the onRune handler that sends the entire file to the language server on every change.

It would be a good idea to use the (undocumented) onBeforeTextEvent(buf, textevent) handler instead. Having access to the textevent makes it feasible to use the more complicated form of textDocumentContentChangeEvent which lets you specify the edited range and the new content of that range.

Andriamanitra avatar May 01 '24 12:05 Andriamanitra