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

Potentially faulty logic in formatAll command #68

Open
Mikle-Bond opened this issue Aug 2, 2023 · 0 comments
Open

Potentially faulty logic in formatAll command #68

Mikle-Bond opened this issue Aug 2, 2023 · 0 comments

Comments

@Mikle-Bond
Copy link

When reviewing the sources, I found this statement.

if (this._textEditor.acceptsTableEdit(row) && re.test(line)) {

The acceptsTableEdit is run on every row. This assumes, that the row belongs to a table, before actually checking if it is part of table.

This actually exposes a faulty behavior in Advanced Tables Obsidian plugin, and noticed in platers/obsidian-lint#827. AT relies on the info provided in the MetadataCache, but by the time the format command is executed, cache is already invalidated. The code in this project implicitly relies on cache, but it doesn't have to.

I think, the correct behavior would be to move this check a bit later, when all the lines that belong to a table already found, and execute acceptsTableEdit on one of the lines. Is there some deeper meaning to the current implementation, that I didn't notice?

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