Skip to content

Incremental updates: replace full re-render with postMessage patching #14

Description

@rayeddev

Problem

Every text change triggers a full panel.webview.html = this.buildHtml(...) re-render. This destroys all webview DOM state: scroll position, search highlights, fold states, and (before v0.3.0) cursor position. The cursor now persists via vscode.getState(), but this is a workaround, not a solution.

Proposed solution

Replace the full HTML assignment with postMessage-based content patching. The extension sends only the changed content to the webview, which applies a targeted DOM update while preserving all other state.

Why it matters

This is the foundation for every stateful feature: section folding, bookmarks, focus mode. Without it, each feature needs its own persistence workaround.

Complexity

High. Requires DOM diffing or a structured patching strategy. Debounce logic needed for rapid typing.

From ideation item #2. Confidence: 90%.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: mediumImportant but not urgentshapingFeature being shaped and refined

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions