Skip to content

[VS Classic] Distinguish multiline and single line completions #9

@olegklimov

Description

@olegklimov

Multi line completion -- should happen when the cursor is on a empty string, or on a string with only spaces.

A typical example of multi line completion:

def do_this_thing():
    |

User hits Enter, IDE provides auto-indent, and then a function body should appear as grey text.

To implement it, the plugin should check if the line is empty or it has only spaces, then delete all the spaces on the empty line (in memory, not in the editor), and then request the model for completions.

It's important to delete spaces before asking the model, because there should be a way for the model to suggest code with less indent. Typical example of this:

int main()
{
    printf("Hello world!\n");
    |

Now the completion is "}", but it will not work unless there are no spaces on that line. With spaces, the model is constrained to "    }".

Now the single line completion should happen when the current line is not empty, and there is nothing except closing special characters on the right:

let right_of_cursor_has_only_special_chars = Boolean(right_of_cursor.match(/^[:\s\t\n\r(){},."'];]*$/));

If multiline=false, the model will return only the remainder of the current line, and stop. The plugin needs to replace the line ending in the editor with the new completion given by the model.

If the cursor is not exactly on the last character of the current line, then #6 about how to deal with that case.

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