Giter Club home page Giter Club logo

Comments (5)

sigmaSd avatar sigmaSd commented on August 19, 2024

yeah I noticed it, I think the best idea is to add debouncing, hopefully its not that hard :)

from irust.

sigmaSd avatar sigmaSd commented on August 19, 2024

@pzmarzly would be great if you test out 55a00e3

from irust.

pzmarzly avatar pzmarzly commented on August 19, 2024

Well, it is fast now, though autocomplete does not trigger after pasting (as due to synchronous nature of the event loop, it doesn't know if a character is the last one). I don't think it's that much of an issue, and changing that would require major changes to IRust. I'm fine with current state.

from irust.

sigmaSd avatar sigmaSd commented on August 19, 2024

Auto complete doesn't trigger after pasting cause I'm not using a real debouncer.
A real debouncer triggers the function after timer expires, something like this

use std::time::{Duration, Instant};

const WAIT_TIMEOUT: u64 = 50;

pub struct Debouncer {
    timer: Instant,
    function: Option<impl Fn>
}

impl Debouncer {
    pub fn new() -> Self {
        Self {
            timer: Instant::now(),
            function: None,
        }
    }

    pub fn start(&mut self) {
        std::thread::spawn(||{
            if self.timer.elapsed() >= Duration::from_millis(WAIT_TIMEOUT) {
                self.function;
            }
        })
    }
    pub fn run(&mut self, mut function: impl FnMut() -> std::io::Result<()>) {
        self.function = Some(function);
        self.timer = Instant::now();
    }
}

Then call start() at the begining of the program so it checks the timer all the time to know when it should trigger the callback
But Its not easy to implement I would need some guidance to make it work

from irust.

sigmaSd avatar sigmaSd commented on August 19, 2024

But I'm also satisfied with current result so we I think we should just leave this for the future^^

from irust.

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.