-
Notifications
You must be signed in to change notification settings - Fork 98
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
Improved source date support #819
Comments
I wonder what the concept is for this. What will be diffed against what? If you have a clear idea how this would work and how it would be a definitive improvement, by all means give it a try. I have to say I have my doubts. I don't think any diff algorithm, no matter how sophisticated, is going to capture what source line dates in SEU capture. In fact, I see any diff-based scheme as basically a step toward ignoring dates (and just using Git) rather than preserving them. But you have exceeded expectations and proved people wrong plenty of times before; maybe this will be one of those times. |
Some progress on testing added lines: /**
* @param {string} alias
* @param {vscode.TextDocument} currentDoc
*/
static calcNewSourceDates(alias, currentDoc) {
const baseDates = allSourceDates[alias].slice();
const oldSource = baseSource[alias];
const eol = (currentDoc.eol === vscode.EndOfLine.LF ? `\n` : `\r\n`);
const diffComputer = new DiffComputer(oldSource.split(eol), currentDoc.getText().split(eol), diffOptions);
const diff = diffComputer.computeDiff();
const currentDate = this.currentStamp();
diff.changes.forEach(change => {
const startIndex = change.modifiedStartLineNumber - 1;
const removedLines = (change.originalEndLineNumber === 0 ? 0 : (change.modifiedEndLineNumber - change.modifiedStartLineNumber + 1));
const changedLines = (change.modifiedEndLineNumber - change.modifiedStartLineNumber) + 1;
baseDates.splice(startIndex, 0, ...Array(changedLines).fill(currentDate));
});
return baseDates;
} |
@jkyeung If the PR gets approved, I would feel more comfy with enabling source dates by default in the future I think. |
Instead of tracking user changes, use a diff tool to determine what lines have changed to rebuild the source dates.
https://github.com/micnil/vscode-diff
The text was updated successfully, but these errors were encountered: