Git Product home page Git Product logo

Comments (16)

dagit avatar dagit commented on July 1, 2024

I discussed this with @glguy and he showed me how word completion works in irc-core.

I also looked into the state of trie libraries on hackage. Here are my conclusions:

  • current state of trie libraries is a bit lackluster for our particular use case
  • tries are overkill for the amount of words we'll be searching
  • Data.Set has nice functions like lookupGT that can be used to find matches

In other words, I think we should do something simple like irc-core and do it directly in the matterhorn code base and not worry about fancy data structures or anything like that. Probably most of the fiddly bits will end up in the UI/UX for this feature.

On that note, glguy mentioned that we might want to consider some of the following things:

  • our source of words may update between requests for completion. For instance, the user is trying to tab-complete channel names while someone else is adding a new channel.
  • we may want to support forward and reverse search when looking for matches. For example, irc-core uses tab and shift+tab for completion and they cycle in a different order.
  • Recently used completion order: most users prefer the search order to be based on what they completed recently. This is helpful if you're switching between a few channels or talking to a few other people.

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

Awesome!

from matterhorn.

glguy avatar glguy commented on July 1, 2024

Another thing to consider is context sensitive tab completion. Users, networks, filenames, and commands all make sense to tab complete in different contexts. Some commands even make sense to have different contexts by parameter. Other commands might do something even more specialized. For example I have /topic tab completing to the current to channel topic when you tab complete with just /topic on its own.

from matterhorn.

dagit avatar dagit commented on July 1, 2024

That's a good point. We mused about feeding argument metadata from #2 to improve completion lists/behavior.

from matterhorn.

dagit avatar dagit commented on July 1, 2024

I've added basic support for tab completion (2dc8a58). It could be a fair bit nicer than it is. Here are some remaining tasks and bugs:

  • after finishing a tab completion pressing space and then tab causes it to complete where it left off in the cycle but at the new cursor position. This is minor but feels weird.
  • We don't do any automatic embellishment of the completions. For example, it might be nice to put a space or a ':' (context dependent) after a completion without disrupting the cycle. Right now it puts the cursor at the end of the suggested word.
  • I haven't spent any time refactoring and cleaning up yet.
  • No support yet for context sensitive completions
  • prioritized completions are possible, but no tracking is done yet of recent completions. It's just a matter of tracking it.
  • We may be sniffing the wrong evens in onEvent (we need to change the completion state in some cases)

That said, please try it out and let me know what you think. I haven't looked for edge cases yet.

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

This is awesome! I'm not sure if this is covered by your list, but I'd like to add:

  • Only complete if there is one completion. If there is more than one, show the alternatives. Completing the first alternative and entering a cycle means users can mistakenly enter the wrong completions (this goes hand-in-hand with showing the alternatives).
  • Show completion options in an overlay (say, just above the editor, in place of the horizontal border there)

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

Regarding one behavior you mentioned about continuing to complete even after the user starts doing other typing, a way to fix that (and a way to enable other behaviors such as the overlay I mentioned) is to make it so that Tab causes a state transition out of the main event handler. Once you've hit Tab you're in completion mode where more Tab and Shift-Tab keystrokes and editing keystrokes have special meaning. When the user hits Space in this mode, you have a chance to exit the mode and do any kind of cleanup you want (such as resetting the completion state). This "mode" might just be a flag to set in the application state but you get the idea.

from matterhorn.

dagit avatar dagit commented on July 1, 2024

Only complete if there is one completion.

Okay, in that case this should be configurable. I prefer the current way when it's combined with prioritized completions.

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

Another approach I can think of that might make us both happy is to give the first completion but show the alternatives so that you know you didn't get the only one. Giving a completion without showing alternatives makes it impossible to tell that you got the right one without hitting Tab again. So I think once we have an alternative-showing overlay, my concern will go away, you'll get the behavior you want, and we won't need configuration (which I'd very much like to avoid for this feature).

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

@dagit you might be interested in aisamanra@3b9fb73 since you had put a comment in the block that I changed.

from matterhorn.

aisamanra avatar aisamanra commented on July 1, 2024

I just recently made some changes to the way commands work—in particular, commands now embed a type that represents the arguments they take. As of now, all those types are variations on Text, but we could embed information about what type they're going to be eventually interpeted as—say, usernames or channel names—and we could in turn use that for extra autocomplete information.

…this might also be a ridiculous amount of overkill. But it's possible!

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

I think that'll be helpful for context-sensitive completion.

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

I just extended this to do something I proposed early on, which is to show alternatives when there is more than one (0a634fb).

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

I'm in favor of calling this "good enough" for our minimal client purposes. Any opposition or other thoughts?

from matterhorn.

dagit avatar dagit commented on July 1, 2024

Good point. I would like to improve it further and refactor it, but it is
getting the job done.

from matterhorn.

jtdaugherty avatar jtdaugherty commented on July 1, 2024

Okay. In that case it sounds like it might be good to create new tickets for specific improvements and close this one.

from matterhorn.

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.