You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to update a field through the manageFieldAtCursorCommand. The note was previously opened in source mode by clicking a link from another note. Positioning the cursor on a field that is defined in the corresponding field class results in "No field with definition at this position" message.
When I edit the opened note in the editor or switch to reading mode and back to source mode, I can update the fields with metadata menu without issues.
It seems to be related to newly opened notes only
Looking into build() and buildSections functions I noticed, that for notes where the update works the line const content = await this.plugin.app.vault.read(this.file); has "\n" as line endings. For notes where the update does not work the same line returns the content with "\r\n" line endings. As result the buildSections() function cannot recognize the frontmatter correctly as I also set the scope to be frontmatter only.
As a bad workaround:
I've changed the build() function to:
buildSections(content) {
var _a, _b;
const yamlLines = [];
let inFrontmatter = false;
let inStartingBlankLines = false;
let frontmatterStart;
let frontmatterEnd;
let startsWithText = false;
let previousLineIsCode = false;
let line_ending = '\n';
if (content.includes('\r\n')) {
line_ending = '\r\n';
}
for (const [i, rawLine] of content.split(line_ending).entries()) {
if (frontmatterEnd === void 0) {
...
This might be related to other update issues that I have also experienced like: #612
The text was updated successfully, but these errors were encountered:
AndreasSachs
changed the title
app.vault.read(this.file) sometimes returns content with "\n" and sometimes with "\r\n", causing different update issues
Files with "\r\n" as line endings, causing different update issues
Jul 12, 2024
I'm trying to update a field through the manageFieldAtCursorCommand. The note was previously opened in source mode by clicking a link from another note. Positioning the cursor on a field that is defined in the corresponding field class results in "No field with definition at this position" message.
When I edit the opened note in the editor or switch to reading mode and back to source mode, I can update the fields with metadata menu without issues.
It seems to be related to newly opened notes only
Looking into build() and buildSections functions I noticed, that for notes where the update works the line
const content = await this.plugin.app.vault.read(this.file);
has "\n" as line endings. For notes where the update does not work the same line returns the content with "\r\n" line endings. As result the buildSections() function cannot recognize the frontmatter correctly as I also set the scope to be frontmatter only.As a bad workaround:
I've changed the build() function to:
and buildSections()
This might be related to other update issues that I have also experienced like:
#612
The text was updated successfully, but these errors were encountered: