intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.54k stars 381 forks source link

Improve struct fields' completion #4448

Closed SomeoneToIgnore closed 3 years ago

SomeoneToIgnore commented 5 years ago

Environment

Problem description

pub struct MouseButtonDown {
    timestamp: u32,
    window_id: u32,
    which: u32,
    mouse_btn: MouseButton,
    clicks: u8,
    x: i32,
    y: i32
}

fn main() {
    let test = MouseButtonDown {/*caret*/}
}

Expected: only field names are available for completion, maybe a bunch of local variables. Actual: let and return are present:

image

Same example as in 1., try to complete any of the fields.

Expected: a semicolon is added if no matching local variables are in scope:

fn main() {
    let test = MouseButtonDown {timestamp: /*caret*/}
}

Actual: I have to add it myself

fn main() {
    let test = MouseButtonDown {timestamp/*caret*/}
}
pub struct MouseButtonDown {
    timestamp: u32,
    window_id: u32,
    which: u32,
    mouse_btn: MouseButton,
    clicks: u8,
    x: i32,
    y: i32,
}

fn get_event() -> MouseButtonDown {
    unimplemented!()
}

fn main() {
    match get_event() {
        MouseButtonDown { /*caret*/ }
    }
}

Expected: only struct field names and .. are available Actual: image

Undin commented 4 years ago

Reopened because we reverted #5659

Kobzol commented 3 years ago

@SomeoneToIgnore I implemented 2) in https://github.com/intellij-rust/intellij-rust/pull/5659, but it maybe it's not such a good idea (https://github.com/intellij-rust/intellij-rust/issues/5875#issuecomment-669428733). Do you still want that functionality or can this issue be closed?

SomeoneToIgnore commented 3 years ago

Oh, don't mind me if you think there are better ways to do something, so go ahead and close it. Thanks for your contriburions!

Kobzol commented 3 years ago

Ok :) I'll close it, since it's unclear if inserting : is always what the user wants, it's a bit unpredictable.