Giter VIP home page Giter VIP logo

Comments (10)

hovsater avatar hovsater commented on August 21, 2024 1

Would it be possible to format the code asynchronously? It's kind of unexpected that it's a synchronous operation blocking the UI.

If not, I think it makes sense for you to be able to opt out. 👍

from helix.

archseer avatar archseer commented on August 21, 2024 1

Sorry about that, I missed the comment! I think some of this overlaps with #177 (comment)

I'd be interested in this, but the async aspects of helix-term still need some work. It's hard to keep a reference in a spawned task without blocking, you'd probably need some sort of a callback mechanism similar to how the LspCallbacks hack works (you keep a DocumentId, the callback gives you a &mut Editor that can be used to look up the doc again).

from helix.

archseer avatar archseer commented on August 21, 2024

This is because we try to :format via the LSP before saving. I was afraid this would be an issue on a slower language server (you can also notice it before rust-analyzer fully boots up). Need to handle that better, probably by making it opt-in per language.

from helix.

archseer avatar archseer commented on August 21, 2024

I think you would likely run into issues if formatting took a while to run async while you made further text edits.

I'll add a config option to enable it only for certain languages.

from helix.

hovsater avatar hovsater commented on August 21, 2024

Yeah, I guess it depends. I've seen it done both ways. If done asynchronously, one could discard the formatting if the buffer changed in between saving the file and the action actually completing.

from helix.

jneem avatar jneem commented on August 21, 2024

I think it does make sense to discard the formatting in that case, but one annoying thing is that you want the formatting to be saved. I guess you'd need to:

  1. make a clone of the document synchronously (cheap, because Ropes clone cheaply)
  2. spawn a "format" task that computes the formatting changes, then spawns a "save" task and returns the formatting changes
  3. the "save" task applies the formatting changes to the cloned document and then saves it
  4. the main task gets the formatting changes from the format task and applies them as long as the document hasn't changed.

I could try implementing that if it sounds reasonable.

from helix.

pickfire avatar pickfire commented on August 21, 2024

Same noticeable delay when I press gd waiting for lsp. It doesn't automatically do the task even though lsp starts up. Should have sort of queuing mechanism.

from helix.

jneem avatar jneem commented on August 21, 2024

Is there no interest in the async formatting version? I like auto-format on save, but I'd also like it not to block the editor...

from helix.

archseer avatar archseer commented on August 21, 2024

Same noticeable delay when I press gd waiting for lsp. It doesn't automatically do the task even though lsp starts up. Should have sort of queuing mechanism.

This is because rust-analyzer takes some time to index before it starts responding to queries. workDone events from LSP will give us a way to cancel these types of queries, at the moment we time out after 2s and then discard the data once received later.

from helix.

archseer avatar archseer commented on August 21, 2024

#285 now solves this, thanks to @jneem for the implementation!

from helix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.