Skip to content

view: table cell edits match source lines instead of compiler ranges #2063

Closed

Description

@shunichironomura

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Found in the review of #2057, which adds the experimental view. It does not block that PR; #2059 fixed the findings that did. Paths refer to #2059's head.

Problem

replaceTableCell in web/view/src/source.ts finds a table cell by matching source lines with regular expressions.

PR #2059 limited the search to the lines inside the declaration's own expression range. It also refuses tables on one line and tables shared by several declarations. That stops an edit from rewriting another declaration's table, but it is a stopgap. These problems remain:

  • A row is split on every ,. A column after atan2(1.0 m, 2.0 m) or max(1.0 W, 2.0 W) is edited at the wrong place; the result fails to compile and is rolled back.
  • In a file with CRLF line endings, no row matches.
  • The row name is put into a RegExp without escaping.
  • In a multi-declaration table, every slot shares one expr, expr_range and line, so no cell can be edited.
  • A table written on one line cannot be edited cell by cell.

As with #2062, the VS Code host writes edits straight into the user's document.

Proposed fix

  • The compiler reports a source range and a slot identity for every editable cell, including the columns of a multi-declaration table.
  • The page only replaces ranges. Cells it cannot edit are shown read-only.
  • Delete replaceTableCell, and replaceExpr, which is unreachable and wrong.

Open question: should the compiler report cell ranges (recommended), or should the page keep parsing tables?

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

    bugSomething isn't workingrustwebviewThe experimental view (web/view, graphcal view, graphcal/viewModel)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions