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

Dead code editor.replaceRange #29

Open
ClementCariou opened this issue Sep 10, 2023 · 0 comments
Open

Dead code editor.replaceRange #29

ClementCariou opened this issue Sep 10, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ClementCariou
Copy link

ClementCariou commented Sep 10, 2023

Plugin informations

  • OS: Windows 10
  • Chesser version: 0.2.0
  • Obsidian version: 1.4.5

Describe the bug
I noticed the function editor.replaceRange is used in Chesser.ts to replace the content of the markdown code block. After some testing, it doesn't seems to work because the view is in read mode when the chessboard view is shown. After some testing, the following code does the trick instead of editor.replaceRange :

view.app.vault.read(view.file).then((content) => {
  const lines = content.split("\n");
  const newContent = lines.slice(0, from.line).join("\n") + "\n" + updated + lines.slice(from.line).join("\n") ;
  view.app.vault.modify(view.file, newContent);
});

Also I suggest storing all the modifications to the markdown code block instead of the localstorage so it can work across devices.

Expected behavior
The markdown block should be updated.

Additional context
I'm trying to contribute to the project.

@ClementCariou ClementCariou added the bug Something isn't working label Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants