Skip to content

Commit

Permalink
Fix LSP completion icon for fields (#4131)
Browse files Browse the repository at this point in the history
Summary:
# Incorrect LSP completion icons for scalar fields

I noticed that the VSCode extension seemed to use weird icons for completion suggestions of _value_ and _text_ for items which are actually _field_s based on the VSCode IntelliSense [docs](https://code.visualstudio.com/docs/editor/intellisense#_types-of-completions). E.g., `String` types were showing up just as plaintext type. All non-struct/union/interface/object types should just be considered a field.

### Before
<img width="813" alt="Screenshot 2022-11-15 at 22 20 32" src="https://user-images.githubusercontent.com/17055343/202040587-7386e0de-d50c-43ac-a5ad-074b9566f32c.png">

### After
<img width="813" alt="Screenshot 2022-11-15 at 22 46 01" src="https://user-images.githubusercontent.com/17055343/202040808-80dee358-5505-4248-b3db-e91e66f4fc2a.png">

Pull Request resolved: #4131

Reviewed By: davidmccabe

Differential Revision: D41322977

Pulled By: rbalicki2

fbshipit-source-id: d0046ee2f162abcc29ac4019bb8955b9c4437176
  • Loading branch information
beaumontjonathan authored and facebook-github-bot committed Nov 16, 2022
1 parent ce5e1ed commit c62cad9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions compiler/crates/relay-lsp/src/completion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,13 +884,10 @@ fn resolve_completion_items_from_fields<T: TypeWithFields + Named>(

let kind = match field.type_.inner() {
Type::Enum(_) => Some(CompletionItemKind::ENUM),
Type::Interface(_) => Some(CompletionItemKind::INTERFACE),
// There is no Kind for union, so we'll use interface
Type::Union(_) => Some(CompletionItemKind::INTERFACE),
Type::Object(_) => Some(CompletionItemKind::STRUCT),
Type::InputObject(_) => Some(CompletionItemKind::STRUCT),
type_ if schema.is_string(type_) => Some(CompletionItemKind::TEXT),
_ => Some(CompletionItemKind::VALUE),
Type::Interface(_) | Type::Union(_) => Some(CompletionItemKind::INTERFACE),
Type::Object(_) | Type::InputObject(_) => Some(CompletionItemKind::STRUCT),
Type::Scalar(_) => Some(CompletionItemKind::FIELD),
};

CompletionItem {
Expand Down

0 comments on commit c62cad9

Please sign in to comment.