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(): 修复在某些场景下错误提示的问题 #1236

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions bricks/vs/src/code-editor/utils/brickNextYaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,40 @@
null,
false
);

const prefixRange = prefixEvaluateOperator?.range;
const suffixRange = suffixEvaluateOperator?.range;

Check warning on line 106 in bricks/vs/src/code-editor/utils/brickNextYaml.ts

View check run for this annotation

Codecov / codecov/patch

bricks/vs/src/code-editor/utils/brickNextYaml.ts#L105-L106

Added lines #L105 - L106 were not covered by tests

const isInEvaluateBody =
prefixEvaluateOperator?.range.startLineNumber &&
suffixEvaluateOperator?.range.startLineNumber &&
prefixEvaluateOperator.range.startLineNumber <= position.lineNumber &&
suffixEvaluateOperator.range.endLineNumber >= position.lineNumber;
prefixRange?.startLineNumber &&
suffixRange?.startLineNumber &&
prefixRange.startLineNumber <= position.lineNumber &&
suffixRange.endLineNumber >= position.lineNumber &&
// 正确匹配当前表达式,防止匹配到上一个表达式<%的开始,下一个表达式的结尾%>
!model.findMatches(
"<%|%>",
new monaco.Range(
prefixRange.endLineNumber,
prefixRange.endColumn,
suffixRange.startLineNumber,
suffixRange.startColumn
),
true,
false,
null,
true
)?.length;

if (isInEvaluateBody) {
const { parentKey: prefixParentKey } = findKeys(
model,
prefixEvaluateOperator.range,
prefixEvaluateOperator?.range.startLineNumber
prefixRange,
prefixRange.startLineNumber
);
const { parentKey: suffixParentKey } = findKeys(
model,
suffixEvaluateOperator.range,
suffixEvaluateOperator?.range.startLineNumber
suffixRange,
suffixRange.startLineNumber
);
Copy link
Contributor Author

@qiaofengxi qiaofengxi Jul 25, 2024

Choose a reason for hiding this comment

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

验证示例:

https://docs-preview-1236--next-bricks.netlify.app/playground/?mode=yaml&example=vs%2Fcode-editor%2Fautomatic+layout+-+fit-container#gzip,H4sIAAAAAAAAE6VWUW8bRRD+K8NJaRMJX1oeL0khdR1alDqhdasijKLx3fi8eL132p0zMU2koCqFByLxABKRUvFCeWyLxENeUP9LVAfzL9Dd2fGdfXYC7NPu3Mw3M9/OztxTq4cdaTlWCRpauG0HusZ2A49K5AkOdF0BUJcUGyfeAnDQJmW7MtZNJQAlQJdFoBxwA2UCSbYM/PhjqIOQNAsaWUtUfoQ+Oam3HUW7vBNHkH7uoozIgb0RcIeMQZ+MHYUeMl04nONytFD7xskKYpsR3qR8dQEqjyvVmu0Ro5CwcCvrSTQd2CvlbVYX8meAxUWJhpdg7RbEmw9tHUiCtbU1qFtojDCMiusWXLsG78UKdoiaBcqlxUkkyAXzefZgS1I+t6AEN7+YNFvKC7I5AHCL1BQdGQqZdtnWFEp0aRK4gMrU3idFGpm8+4HbNkUak7TNIi9dG1XbJ/44h1rAzv/gKF1LReI8X6N7X12Acu2Jnc90SreQX7hKmY7WDI7hSjzDqIivFGqsGxna1kFXeKQduE5oekFobAyF7Xa8hi1UXK0uffQoeXf3hsfHHzg37Rv2jev/OoP7W3cqmztbtz+plGuXxN8JPJIXEdzzCjIgaajA1YjqFipP0l3msKJ12sKuGGoJ/vrxl/PvfoBO4Lbh/Kc350ev+r/+Pvjj5Ui7EZme7bZQ+dkILn1IUx5LiYvbkenlpbM6EUYcdJCFu4m9IGIHmoJLiTvFw9YqVNtkWnK59mR82Kim+w7qNumsWtLPHdher90dRzLskw6cHZwM3h6f//w6UTg7eDHWkdQl6UBL8BTYp48qDz6bi5ZoFMEJ1Qym8Nar5btbD+YCpipnBydTiF+hVlOID2vrtUoBYN0avD3++9vv350eDZ792X9+PNS0pmApX1rxyMxd8HCU1a3B69/Onx32T970XxxkcQAYtU/sQIs5NM7ycjISS/FItL80dqD9ZS9wzbIbKJdCTjZxdU0lU9venJt1Jr93p0f9w28Gr077z4/7hy8vLN2gE0rifGlIbMRQjYg5UFXsZOo5rU4HDGuh/BkmtV5YYFK3Qi06qHt7HjUxkrwXV+6eFz8pPSZoAuuh+DqDJZQhzTXaZQfMxRf0unHL8MrTyQypHiOwFr5PutxCjS7HXbBuOdnrKWAkFxYWShuplHZZ46ZoZNlsCknbyC0HGmjI9mw2WW/JS878+qSUuRI1gcIOmRBdih81PM13rniwMIToU02wpNGdrBRpxUBzFbBQ2shJ91fmx7hRnQyxGamkQYJPvI0+3UlKYXFpZbbaaORMKF3mO+5SxQSNB8p/Y+gyz0lHK3YdT4fuLMf71vuWj6HlNFEa2v8HsZhs5JALAAA=

const { keyList } = findKeys(model, word, position.lineNumber);
if (
Expand Down Expand Up @@ -151,7 +169,7 @@
};
const DSToken = tokenConfig.showDSKey ? ["CTX.DS", "DS"] : [];
const word = model.getWordUntilPosition(position);
const { word: prefixWord, token: _prefixToken } = getPrefixWord(
const { word: prefixWord, token: prefixToken } = getPrefixWord(

Check warning on line 172 in bricks/vs/src/code-editor/utils/brickNextYaml.ts

View check run for this annotation

Codecov / codecov/patch

bricks/vs/src/code-editor/utils/brickNextYaml.ts#L172

Added line #L172 was not covered by tests
model,
position,
tokenConfig
Expand Down Expand Up @@ -277,7 +295,7 @@
}
}

if (isInEvaluateBody(model, position)) {
if (isInEvaluateBody(model, position) && prefixToken !== ":") {
const embeddedContext = EmbeddedModelContext.getInstance(id);

const suggestions = await provideJsSuggestItems(
Expand Down
Loading