Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwaggerEditor@next: Autocomplete for $ref fields with additional character #3216

Closed
char0n opened this issue Jul 6, 2022 · 11 comments
Closed

Comments

@char0n
Copy link
Member

char0n commented Jul 6, 2022

From the user:

I've noticed a bug on AsyncApi editor. Autocompletion doesn't work when I write $ref: "here use a letter which occurs in path in your domain" and then I click ctrl+space. Please see attached video

videoAutocomplition.mov
@char0n
Copy link
Member Author

char0n commented Jul 6, 2022

This is interesting corner case. When you start typing $ref: and hit ctrl+space then you get autocomplete suggestions and if you write further characters then the autocomplete items filter them self and highlight them self matching what you wrote.
But...when you start typing $ref: c and hit ctrl+space, then no autocompletion is shown. The expected behavior would be to show autocomplete items already filtered and matched to c character

@frantuma
Copy link
Member

frantuma commented Apr 20, 2023

Adding some related notes:

  • adding matchOnWordStartOnly: false, in editor options might help, but not sufficient

  • regardless of the above it doesn't work when current text and/or returned item starts with #/ or #,

  • can be also possibly related with wrong/missing range returned in completion item
    SEE Disable suggestions filter microsoft/monaco-editor#1889

  • maybe also possibly already filtered out by language service itself, to be investigate

@char0n
Copy link
Member Author

char0n commented Apr 27, 2023

Confirmed that language service doesn't return any completion items. It's an issue within apidom-ls.

@char0n
Copy link
Member Author

char0n commented Apr 27, 2023

Standard usecases like the following have been fixed by replacing unquotedOriginalInsertText?.startsWith(word) with unquotedOriginalInsertText?.includes(word).

$ref: user<cursor>

@char0n
Copy link
Member Author

char0n commented Apr 27, 2023

regardless of the above it doesn't work when current text and/or returned item starts with #/ or #,

@frantuma yes, that is expected. # is control character for starting of the YAML comment. Thus it's dropped from the resulting AST. You have to escape it with single or double quotes to represent the value. Following notations works correctly:

$ref: "#<cursor>"
$ref: "<cursor>#"
$ref: '#<cursor>'
$ref: '<cursor>#'
$ref:<cursor> # comment

The only case that behaves IMHO unexpectedly is the following one:

$ref: <cursor> # comment

Instead of $ref suggestions, it gives us Schema Object fields suggestion.

char0n added a commit to swagger-api/apidom that referenced this issue Apr 27, 2023
Before this change, completion items were only
provided if they started by the filtered text.

With this change, completion items are provided
if they include filtered text.

Refs swagger-api/swagger-editor#3216
char0n added a commit to swagger-api/apidom that referenced this issue Apr 27, 2023
Before this change, completion items were only
provided if they started by the filtered text.

With this change, completion items are provided
if they include filtered text.

Refs swagger-api/swagger-editor#3216
@char0n
Copy link
Member Author

char0n commented Apr 27, 2023

Upstream ApiDOM@0.69.3 released with bugfix: https://github.com/swagger-api/apidom/releases/tag/v0.69.3

char0n added a commit that referenced this issue Apr 27, 2023
This bugfix is provided mainly via ApiDOM@0.69.3 update.

Refs #3216
char0n added a commit that referenced this issue Apr 27, 2023
…4072)

This bugfix is provided mainly via ApiDOM@0.69.3 update.

Refs #3216
swagger-bot pushed a commit that referenced this issue Apr 27, 2023
# [5.0.0-alpha.58](v5.0.0-alpha.57...v5.0.0-alpha.58) (2023-04-27)

### Bug Fixes

* **language-apidom:** aprovide document links with non-empty ranges ([#4069](#4069)) ([34a8eab](34a8eab)), closes [#3216](#3216)
* **language-apidom:** provide completion items with proper filtering ([#4072](#4072)) ([d460e16](d460e16)), closes [#3216](#3216)
@char0n
Copy link
Member Author

char0n commented Apr 27, 2023

@char0n char0n closed this as completed Apr 27, 2023
@frantuma
Copy link
Member

@char0n

The only case that behaves IMHO unexpectedly is the following one:
$ref: # comment

not sure if this was fixed somehow as I am not able to reproduce, I am however able to reproduce a similar behaviour by:

ctrl+click on $ref: #/com<cursor> (no results) and then hit left arrow (schema properties appear)

might be worth adding this to own ticket.


regardless of the above it doesn't work when current text and/or returned item starts with #/ or #,

@frantuma yes, that is expected. # is control character for starting of the YAML comment. Thus it's dropped from the resulting AST. You have to escape it with single or double quotes to represent the value. Following notations works correctly:

I understand your point, still (for future reference in case) it might be a better experience for the user to have completion triggered also in case:

$ref: #<cursor> or $ref: #/<cursor> . This might need some "hack" in apidom-ls completion service node interpretation. Possibly also this to be added to own ticket..


Last point not fully related to bug reported in this ticket, it might be good to tweak editor properties as below.
Specifically quickSuggestions: { other: true, strings: true }, seems to help in triggering completion after key press within ref values.

quickSuggestions: { other: true, strings: true },
matchOnWordStartOnly: false,
suggest: {
  snippetsPreventQuickSuggestions: false,
  showValues: true,
},

@char0n
Copy link
Member Author

char0n commented May 10, 2023

not sure if this was fixed somehow as I am not able to reproduce, I am however able to reproduce a similar behaviour by:
ctrl+click on $ref: #/com (no results) and then hit left arrow (schema properties appear)
might be worth adding this to own ticket.

Transformed into separate #4108 with Steps Of Reproduction recorded as video.

@char0n
Copy link
Member Author

char0n commented May 10, 2023

I understand your point, still (for future reference in case) it might be a better experience for the user to have completion triggered also in case:
$ref: # or $ref: #/ . This might need some "hack" in apidom-ls completion service node interpretation. Possibly also this to be added to own ticket..

Transformed into separate #4109.

@char0n
Copy link
Member Author

char0n commented May 10, 2023

Last point not fully related to bug reported in this ticket, it might be good to tweak editor properties as below.
Specifically quickSuggestions: { other: true, strings: true }, seems to help in triggering completion after key press within ref values.

Transformed into separate #4110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants