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

code block diffs instead of replaces #1111

Open
Shadlock0133 opened this issue Mar 20, 2023 · 0 comments
Open

code block diffs instead of replaces #1111

Shadlock0133 opened this issue Mar 20, 2023 · 0 comments

Comments

@Shadlock0133
Copy link

It's probably wouldn't be easy to add, but having diffs instead of replaces would help with readability, as (at least for me) trying to find from surrounding lines what code to replace is difficult. E.g.

currently:

  uint8_t arg = identifierConstant(&name);

  // replaces 1 line
  if (match(TOKEN_EQUAL)) {
    expression();
    emitBytes(OP_SET_GLOBAL, arg);
  } else {
    emitBytes(OP_GET_GLOBAL, arg);
  }
}

with diff:

  uint8_t arg = identifierConstant(&name);

-  emitBytes(OP_GET_GLOBAL, arg);
+  if (match(TOKEN_EQUAL)) {
+    expression();
+    emitBytes(OP_SET_GLOBAL, arg);
+  } else {
+    emitBytes(OP_GET_GLOBAL, arg);
+  }
}

Diffs could also be split into two columns, with left being old code, and new code on the right.

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

No branches or pull requests

1 participant