vscode-ibmi
vscode-ibmi copied to clipboard
Improved source date support
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
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.