Skip to content

feat: preview ready sync scene#607

Closed
A-kirami wants to merge 1 commit into
OpenWebGAL:devfrom
A-kirami:feat/preview-ready-sync-scene
Closed

feat: preview ready sync scene#607
A-kirami wants to merge 1 commit into
OpenWebGAL:devfrom
A-kirami:feat/preview-ready-sync-scene

Conversation

@A-kirami

Copy link
Copy Markdown
Contributor

变更内容

  • EditorLineHolder 中新增 getSceneLineOrFirstLine,统一处理场景同步行号回退规则
  • GraphicalEditor 在预览 ready 后按记录行号同步当前场景,未记录时同步第 1 行
  • TextEditor 在预览 ready 后不再使用 Monaco 默认 position 兜底,避免无明确光标记录时同步到非预期行

行为变化

  • 打开实时预览并进入编辑页面后,预览 ready 时会同步当前打开的场景文件
  • 有记录光标行时同步当前行
  • 无记录光标行时同步第 1 行
  • 当前实现会通过既有预览命令分发链路同步到已连接预览,不限定为 embedded preview

已知边界

  • 本次暂不区分 embedded preview 和其他已连接预览
  • 后续如果需要只同步 embedded preview,需要在 host/editor 协议或分发层补充更明确的目标路由

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a standardized method getSceneLineOrFirstLine within the EditorLineHolder class and updates both the GraphicalEditor and TextEditor components to use it for line synchronization. Feedback suggests further unifying the scenePath used in TextEditor to props.targetPath to ensure consistency with GraphicalEditor and prevent potential synchronization errors in multi-editor scenarios.

Comment on lines +135 to 137
const lineNumber = editorLineHolder.getSceneLineOrFirstLine(props.targetPath);
EditorPreviewClient.sendSyncScene({
scenePath: target?.path ?? '',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

syncCurrentLine 中,scenePath 使用了 target?.path。这与 GraphicalEditor 的实现不一致,且在多编辑器实例并存(如多页签模式)的情况下,可能会导致非活跃状态的编辑器在响应同步事件时,将自身的行号数据同步到当前活跃页面的路径上,从而引发预览错乱。建议统一使用 props.targetPath 以确保同步路径的准确性。

Suggested change
const lineNumber = editorLineHolder.getSceneLineOrFirstLine(props.targetPath);
EditorPreviewClient.sendSyncScene({
scenePath: target?.path ?? '',
const lineNumber = editorLineHolder.getSceneLineOrFirstLine(props.targetPath);
EditorPreviewClient.sendSyncScene({
scenePath: props.targetPath,

@A-kirami A-kirami changed the title Feat/preview ready sync scene feat: preview ready sync scene May 24, 2026
@A-kirami A-kirami closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant