Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js2-mode and derived modes displays lag when typing in large files (300 lines of code or more) #588

Closed
shackra opened this issue Jan 1, 2019 · 4 comments
Assignees

Comments

@shackra
Copy link
Contributor

shackra commented Jan 1, 2019

Describe the bug
When lsp-mode is turned on in js2-mode and derived modes, like rjsx-mode, typing is a painful experience full of lag (1 or 2 seconds or even more depending on how fast you are writing code).

To Reproduce
Steps to reproduce the behavior:

  1. Run emacs -q
  2. Load the configuration bug.txt.
  3. Download and uncompressed the frontend of one of my projects
    fero.zip
  4. visit the file src/components/Invoice/detalle.jsx
  5. finally, go anywhere and hold any key, you should see lag.
  6. extra: put :disabled under (use-package lsp to disabled lsp-mode, then try to reproduce, you will see that typing is smooth again.

Expected behavior
no lag at all like typing in large files with go-mode or python-mode and lsp-mode running.

Which Language Server did you use
this is included with the configuration.

OS
GNU/Linux (Arch)

This happens with lsp-mode version 20181228.819 and only on js2-mode derived modes.

@yyoncho
Copy link
Member

yyoncho commented Jan 1, 2019

The issue is caused by the fact that the typescript language synchronization is full and when you press and hold a key lsp-mode has to send whole file content as a message which is problematic. We should introduce some mechanisim for handling that case or even #362

@shackra I would suggest switching to the other javascript language server which seems to be smarter and also supports partial updates(these lines will fix the perf issue).

 (setq lsp-clients-typescript-server "typescript-language-server"
       lsp-clients-typescript-server-args '("--stdio"))

@alanz @MaskRay

@MaskRay
Copy link
Member

MaskRay commented Jan 1, 2019

  1. This is apparently a server issue
  2. I don't think grouping texDocument/didChange is necessary
// src/typescript-service.ts
    public async textDocumentDidChange(params: DidChangeTextDocumentParams): Promise<void> {
        const uri = normalizeUri(params.textDocument.uri)
        let text: string | undefined
        for (const change of params.contentChanges) {
            if (change.range || change.rangeLength) {
                throw new Error('incremental updates in textDocument/didChange not supported for file ' + uri)
            }
            text = change.text
        }
        if (!text) {

@shackra
Copy link
Contributor Author

shackra commented Jan 1, 2019

@shackra I would suggest switching to the other javascript language server which seems to be smarter and also supports partial updates(these lines will fix the perf issue).

 (setq lsp-clients-typescript-server "typescript-language-server"
       lsp-clients-typescript-server-args '("--stdio"))

Ah, indeed @yyoncho, the current typescript server is javascript-typescript-stdio, I will switch as you recommend.

shackra added a commit to shackra/emacs that referenced this issue Jan 1, 2019
Hay un bug con el servidor actual, javascript-typescript-stdio, que releentiza la edición de código
en rjsx-mode.

Feliz año nuevo y feliz solemnidad de María madre de Dios :)

- emacs-lsp/lsp-mode#588
@yyoncho
Copy link
Member

yyoncho commented Jan 2, 2019

@MaskRay IMO it is not server side issue since full sync is a valid option according to latest LSP spec and we should provide reasonable handling/performance. I am thinking about adding client-side debounce only for full sync text messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants