Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic DateTime Updates are Triggered Twice When File Doesn't Have Trailing Newline

See original GitHub issue

Describe the bug When frontMatter.content.autoUpdateDate is enabled and editing a document that doesn’t have a trailing newline, the automatic date updates are triggered twice. This doesn’t happen when the file does have a trailing new line. For example, after it updates twice (the newline is added for you), subsequent updates happen only once.

To Reproduce Steps to reproduce the behavior:

  1. Ensure frontMatter.content.autoUpdateDate is enabled.
  2. Try to update a markdown (or MDX) file and wait for the debounce to trigger the autoupdate.
  3. Observe that the lastmod field is updated twice.

Expected behavior I’d expect the lastmod field to be updated only once.

Screenshots A gif which demonstrates the behavior: example

VS Code Version

Version: 1.63.2 (Universal)
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:37:28.172Z (2 wks ago)
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
OS: Darwin arm64 21.2.0

Extension Version v5.9.0

Additional context This is likely due to the autoupdate logic defined here:

One way to solve this might be to adjust the change detection logic, but this may introduce new bugs.

Another possible solution would be to do away with change detection entirely-- moving away from vscode.workspace.onDidChangeTextDocument to onWillSaveTextDocument: . This would move auto-updates to the pre-save lifecycle which would prevent the extension from updating the lastmod timestamp while the user is actively editing the document.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

estruyfcommented, Jan 7, 2022

I’ve merged your PR @farmerau, thanks again for the help on this one! 🙏

Included a check for the gray-matter new line as well. When the content does not contain a newline before the stringify function, it will remove it when included. Combined with your change, I think this will complete the issue.

estruyfcommented, Jan 6, 2022

Let us give it a try!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the significance of the "No newline at end of file" log?
It indicates that you do not have a newline (usually \n , aka LF or CRLF) at the end of file. That is,...
Read more >
How to add a newline to the end of a file? - Unix StackExchange
The code works because sed by default appends a newline to its output if it is not already there. The code "$a\" just...
Read more >
SUSE-CU-2022:969-1: Security update of bci/python
The following patches have been included in this update: ... the initial build of python3-base does not trigger the automatic installation.
Read more >
Automate Desktop and Automate Plus/Ultimate - Fortra
The SharePoint Trigger now properly fires tasks and workflows. NOTE: The SharePoint trigger has been updated to use Transmission Control Protocol (TCP).
Read more >
IBM Informix Messages and Corrections
The database server has called the isbopen function twice in a row. If the error recurs, note all circumstances and contact IBM Informix...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found