1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2024-11-28 08:48:48 +02:00

Возврат различий в режиме сравнения #306

This commit is contained in:
salexdv 2023-01-21 17:24:02 +03:00
parent 72a2ab5a2d
commit 7ec4eb0b5b

View File

@ -1516,6 +1516,50 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
}
getDifferences = function () {
let diff = [];
if (editor.navi) {
diff = editor.getLineChanges();
let original_model = editor.originalEditor.getModel();
let modified_model = editor.modifiedEditor.getModel();
diff.forEach(function (value) {
value["originalText"] = getTextInLines(original_model, value.originalStartLineNumber, value.originalEndLineNumber);
value["modifiedText"] = getTextInLines(modified_model, value.modifiedStartLineNumber, value.modifiedEndLineNumber);
if (Array.isArray(value.charChanges)) {
value.charChanges.forEach(function (char) {
char["originalText"] = getTextInRange(
original_model,
char.originalStartLineNumber,
char.originalStartColumn,
char.originalEndLineNumber,
char.originalEndColumn
);
char["modifiedText"] = getTextInRange(
modified_model,
char.modifiedStartLineNumber,
char.modifiedStartColumn,
char.modifiedEndLineNumber,
char.modifiedEndColumn
);
});
}
});
}
return diff;
}
generateEventWithSuggestData = function(eventName, trigger, row, suggestRows = []) {
let bsl = new bslHelper(editor.getModel(), editor.getPosition());
@ -1816,7 +1860,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
}
// #endregion
// #region non-public functions
// #region non-public functions
generateEscapeEvent = function() {
let position = editor.getPosition();
@ -1836,6 +1880,36 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
}
function getTextInLines(model, startLineNumber, endLineNumber) {
let text = '';
if (endLineNumber >= startLineNumber) {
let range = {
startLineNumber: startLineNumber,
startColumn: 1,
endLineNumber: endLineNumber,
endColumn: model.getLineMaxColumn(endLineNumber),
}
text = model.getValueInRange(range);
}
return text;
}
function getTextInRange(model, startLineNumber, startColumn, endLineNumber, endColumn) {
let range = {
startLineNumber: startLineNumber,
startColumn: startColumn,
endLineNumber: endLineNumber,
endColumn: endColumn,
}
return model.getValueInRange(range);
}
function getLineNumberMargin(originalLineNumber) {
let margin = '';