Coder Social home page Coder Social logo

Comments (6)

fdncred avatar fdncred commented on June 9, 2024 1

ok, I guess the problem is that movetolineend will never fail, same with movetolinestart, so I'm guessing you'd never get to the last command in the until.

from reedline.

fdncred avatar fdncred commented on June 9, 2024

On both of your keybindings you're using until. until means "run these things in order until one works". I'm wondering if that's what you're meaning to do.

Here's how you might change the first one.

  {
    name: move_to_line_end_or_take_history_hint
    modifier: control
    keycode: char_e
    mode: [emacs, vi_normal, vi_insert]
    event: [
        {send: historyhintcomplete}
        {edit: movetolineend}
        {send: openeditor} 
    ]
  }

You can do something similar with your other one too.

from reedline.

101313 avatar 101313 commented on June 9, 2024

On both of your keybindings you're using until. until means "run these things in order until one works". I'm wondering if that's what you're meaning to do.

I think this is indeed what I would like to do. Unless you can conditionally sequence commands in other ways.

In essence, inside until commands take precedence by their order. In my example that would translate, if there is a suggestion take it, otherwise movetolineend and if that fails as well, which should when you're at the end already, then you may open the editor.

Not sure what the proposed solution does exactly, I would assume executing the commands, one after the other, but I don't think I've ever seen that being done outside of an until. At least, that is the case in the default config.

from reedline.

101313 avatar 101313 commented on June 9, 2024

ok, I guess the problem is that movetolineend will never fail, same with movetolinestart, so I'm guessing you'd never get to the last command in the until.

Yes, pretty much. I think its more reasonable for the other way around besides being more practical.

from reedline.

sholderbach avatar sholderbach commented on June 9, 2024

Yes our EditCommand operations are all infallible at the moment so they will never say that they were not handled.

Here all roads lead to EventStatus::Handled.

reedline/src/engine.rs

Lines 1148 to 1190 in b1344f6

ReedlineEvent::Edit(commands) => {
self.run_edit_commands(&commands);
if let Some(menu) = self.menus.iter_mut().find(|men| men.is_active()) {
if self.quick_completions && menu.can_quick_complete() {
match commands.first() {
Some(&EditCommand::Backspace)
| Some(&EditCommand::BackspaceWord)
| Some(&EditCommand::MoveToLineStart) => {
menu.menu_event(MenuEvent::Deactivate)
}
_ => {
menu.menu_event(MenuEvent::Edit(self.quick_completions));
menu.update_values(
&mut self.editor,
self.completer.as_mut(),
self.history.as_ref(),
);
if let Some(&EditCommand::Complete) = commands.first() {
if menu.get_values().len() == 1 {
return self
.handle_editor_event(prompt, ReedlineEvent::Enter);
} else if self.partial_completions
&& menu.can_partially_complete(
self.quick_completions,
&mut self.editor,
self.completer.as_mut(),
self.history.as_ref(),
)
{
return Ok(EventStatus::Handled);
}
}
}
}
}
if self.editor.line_buffer().get_buffer().is_empty() {
menu.menu_event(MenuEvent::Deactivate);
} else {
menu.menu_event(MenuEvent::Edit(self.quick_completions));
}
}
Ok(EventStatus::Handled)
}

To allow more until shenanigans, we would need to make each of the edit operations explicit about their return status. Then you could reorder them more freely.

Moving this over to reedline as the changes would need to happen here.

from reedline.

Abdillah avatar Abdillah commented on June 9, 2024

I have two related issues open regarding until too: #603 and #604.

If time suffice and no one taking, this is a one-strike issue after my #608 to pull it off.

from reedline.

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.