Skip to content

Commit b8eb99b

Browse files
authored
fix: method highlighting failure during initialization (#1664)
1 parent 6f3a17c commit b8eb99b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/plugins/script/src/js/method.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const setEditorSelection = () => {
193193
)
194194
}
195195

196-
export const highlightMethod = (name) => {
196+
export const highlightMethod = async (name) => {
197197
if (!name) {
198198
return
199199
}
@@ -216,6 +216,9 @@ export const highlightMethod = (name) => {
216216
}
217217

218218
if (state.editorSelection) {
219+
// 兼容初始化进来时,state.script 为空,需要等待一个 tick 之后再设置选中
220+
// 否则直接设置选中,此时 state.script 为空,设置无效
221+
await nextTick()
219222
setEditorSelection()
220223
}
221224
}

0 commit comments

Comments
 (0)