Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Better autocompletion example #3

@xmedeko

Description

@xmedeko

I find the autocompletion example somewhat not usable. What about

var completions = new string[] { "status", "help", "state", "stx" };

// Configures auto-completion, in this example, the result
// is always to offer the numbers as completions
le.AutoCompleteEvent += delegate (string text, int pos) {
    string prefix = text.Substring(0, pos);
    string[] autocompletions;
    if (string.IsNullOrEmpty(prefix))
        autocompletions = completions;
    else
        autocompletions = completions
            .Where(c => c.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
            .Select(c => c.Substring(pos))
            .ToArray();
        return new Mono.Terminal.LineEditor.Completion(prefix, autocompletions);
};

It just have disadvantage, that it works on the line beginning only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions