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

Fix #40941 - Suggest trigger at language boundaries #43349

Merged
merged 3 commits into from
Mar 20, 2018
Merged

Conversation

mjbvz
Copy link
Collaborator

@mjbvz mjbvz commented Feb 9, 2018

Fixes #40941

Bug
Suggestions not auto triggered when you type x in const z = <div x>. See #40941 (comment) for explaination of root cause

Proposed fix
In the case where suggestions are triggered at the boundary between two languages, I believe we should trigger. This change adds special logic to handle that case by making sure we check the word at the previous character position instead of at the current character positon when at language boundaries

@mjbvz mjbvz self-assigned this Feb 9, 2018
@@ -46,7 +46,19 @@ export class LineContext {
}
const pos = editor.getPosition();
model.tokenizeIfCheap(pos.lineNumber);
const word = model.getWordAtPosition(pos);

// When we are at an embedded language boundary, check the word at the previous character
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This some pretty ugly logic. Let me know if there is some better way to express this

@mjbvz mjbvz requested review from alexdima and jrieken March 7, 2018 23:42
@mjbvz mjbvz added this to the March 2018 milestone Mar 7, 2018
Copy link
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to @alexandrudima about this and the outcome is that getWordAtPosition should be fixed instead of the consumer. Today the function is biased towards the right but it should look left when (1) there was no result on the right and (2) when it started at a language-border.

@mjbvz
Copy link
Collaborator Author

mjbvz commented Mar 16, 2018

Ok, I didn't do that initially because I was concerned about regressions. I've pushed an update that moves the fix into getWordAtPosition

Take a look at the test case for getWordAtPosition and embedded languages and let me know if you think the new behavior makes sense

Fixes #40941

**Bug**
Suggestions not auto triggered when you `x` in `const z = <div x>`. See #40941 (comment) for explaination of root cause

**Proposed fix**
In the case where suggestions are triggered at the boundary between two languages, I believe we should trigger. This change adds special logic to handle that case by making sure we check the word at the  previous character position instead of at the current character positon when at language boundaries
@alexdima
Copy link
Member

alexdima commented Mar 20, 2018

👍
I fixed an issue where LanguageConfigurationRegistry.getWordDefinition(languageId) was used for the left biased word, but languageId was the language for the right biased word.

@alexdima alexdima merged commit 36d78fa into master Mar 20, 2018
@joaomoreno joaomoreno deleted the fix-40941 branch April 30, 2018 08:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no property autocomplete in JSX(related with an empty space)
3 participants