mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
This reverts commit d15a3fcc98.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
"description": "%description%",
|
||||
"icon": "resources/icons/merge-conflict.png",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
|
||||
"engines": {
|
||||
"vscode": "^1.5.0"
|
||||
@@ -115,21 +114,6 @@
|
||||
"type": "boolean",
|
||||
"description": "%config.autoNavigateNextConflictEnabled%",
|
||||
"default": false
|
||||
},
|
||||
"merge-conflict.diffViewPosition": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Current",
|
||||
"Beside",
|
||||
"Below"
|
||||
],
|
||||
"description": "%config.diffViewPosition%",
|
||||
"enumDescriptions": [
|
||||
"%config.diffViewPosition.current%",
|
||||
"%config.diffViewPosition.beside%",
|
||||
"%config.diffViewPosition.below%"
|
||||
],
|
||||
"default": "Current"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,6 +122,6 @@
|
||||
"vscode-nls": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^10.14.8"
|
||||
"@types/node": "8.0.33"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,5 @@
|
||||
"config.title": "Merge Conflict",
|
||||
"config.autoNavigateNextConflictEnabled": "Whether to automatically navigate to the next merge conflict after resolving a merge conflict.",
|
||||
"config.codeLensEnabled": "Create a Code Lens for merge conflict blocks within editor.",
|
||||
"config.decoratorsEnabled": "Create decorators for merge conflict blocks within editor.",
|
||||
"config.diffViewPosition": "Controls where the diff view should be opened when comparing changes in merge conflicts.",
|
||||
"config.diffViewPosition.current": "Open the diff view in the current editor group.",
|
||||
"config.diffViewPosition.beside": "Open the diff view next to the current editor group.",
|
||||
"config.diffViewPosition.below": "Open the diff view below the current editor group."
|
||||
"config.decoratorsEnabled": "Create decorators for merge conflict blocks within editor."
|
||||
}
|
||||
@@ -88,54 +88,18 @@ export default class CommandHandler implements vscode.Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
const conflicts = await this.tracker.getConflicts(editor.document);
|
||||
|
||||
// Still failed to find conflict, warn the user and exit
|
||||
if (!conflicts) {
|
||||
vscode.window.showWarningMessage(localize('cursorNotInConflict', 'Editor cursor is not within a merge conflict'));
|
||||
return;
|
||||
}
|
||||
|
||||
const scheme = editor.document.uri.scheme;
|
||||
let range = conflict.current.content;
|
||||
let leftRanges = conflicts.map(conflict => [conflict.current.content, conflict.range]);
|
||||
let rightRanges = conflicts.map(conflict => [conflict.incoming.content, conflict.range]);
|
||||
|
||||
const leftUri = editor.document.uri.with({
|
||||
scheme: ContentProvider.scheme,
|
||||
query: JSON.stringify({ scheme, range: range, ranges: leftRanges })
|
||||
query: JSON.stringify({ scheme, range })
|
||||
});
|
||||
|
||||
|
||||
range = conflict.incoming.content;
|
||||
const rightUri = leftUri.with({ query: JSON.stringify({ scheme, ranges: rightRanges }) });
|
||||
|
||||
let mergeConflictLineOffsets = 0;
|
||||
for (let nextconflict of conflicts) {
|
||||
if (nextconflict.range.isEqual(conflict.range)) {
|
||||
break;
|
||||
} else {
|
||||
mergeConflictLineOffsets += (nextconflict.range.end.line - nextconflict.range.start.line) - (nextconflict.incoming.content.end.line - nextconflict.incoming.content.start.line);
|
||||
}
|
||||
}
|
||||
const selection = new vscode.Range(
|
||||
conflict.range.start.line - mergeConflictLineOffsets, conflict.range.start.character,
|
||||
conflict.range.start.line - mergeConflictLineOffsets, conflict.range.start.character
|
||||
);
|
||||
const rightUri = leftUri.with({ query: JSON.stringify({ scheme, range }) });
|
||||
|
||||
const title = localize('compareChangesTitle', '{0}: Current Changes ⟷ Incoming Changes', fileName);
|
||||
const mergeConflictConfig = vscode.workspace.getConfiguration('merge-conflict');
|
||||
const openToTheSide = mergeConflictConfig.get<string>('diffViewPosition');
|
||||
const opts: vscode.TextDocumentShowOptions = {
|
||||
viewColumn: openToTheSide === 'Beside' ? vscode.ViewColumn.Beside : vscode.ViewColumn.Active,
|
||||
selection
|
||||
};
|
||||
|
||||
if (openToTheSide === 'Below') {
|
||||
await vscode.commands.executeCommand('workbench.action.newGroupBelow');
|
||||
}
|
||||
|
||||
await vscode.commands.executeCommand('vscode.diff', leftUri, rightUri, title, opts);
|
||||
vscode.commands.executeCommand('vscode.diff', leftUri, rightUri, title);
|
||||
}
|
||||
|
||||
navigateNext(editor: vscode.TextEditor): Promise<void> {
|
||||
|
||||
@@ -23,27 +23,11 @@ export default class MergeConflictContentProvider implements vscode.TextDocument
|
||||
|
||||
async provideTextDocumentContent(uri: vscode.Uri): Promise<string | null> {
|
||||
try {
|
||||
const { scheme, ranges } = JSON.parse(uri.query) as { scheme: string, ranges: [{ line: number, character: number }[], { line: number, character: number }[]][] };
|
||||
const { scheme, range } = JSON.parse(uri.query) as { scheme: string; range: { line: number, character: number }[] };
|
||||
const [start, end] = range;
|
||||
|
||||
// complete diff
|
||||
const document = await vscode.workspace.openTextDocument(uri.with({ scheme, query: '' }));
|
||||
|
||||
let text = '';
|
||||
let lastPosition = new vscode.Position(0, 0);
|
||||
|
||||
ranges.forEach(rangeObj => {
|
||||
let [conflictRange, fullRange] = rangeObj;
|
||||
const [start, end] = conflictRange;
|
||||
const [fullStart, fullEnd] = fullRange;
|
||||
|
||||
text += document.getText(new vscode.Range(lastPosition.line, lastPosition.character, fullStart.line, fullStart.character));
|
||||
text += document.getText(new vscode.Range(start.line, start.character, end.line, end.character));
|
||||
lastPosition = new vscode.Position(fullEnd.line, fullEnd.character);
|
||||
});
|
||||
|
||||
let documentEnd = document.lineAt(document.lineCount - 1).range.end;
|
||||
text += document.getText(new vscode.Range(lastPosition.line, lastPosition.character, documentEnd.line, documentEnd.character));
|
||||
|
||||
const text = document.getText(new vscode.Range(start.line, start.character, end.line, end.character));
|
||||
return text;
|
||||
}
|
||||
catch (ex) {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/node@^10.14.8":
|
||||
version "10.14.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
|
||||
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
|
||||
"@types/node@8.0.33":
|
||||
version "8.0.33"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.33.tgz#1126e94374014e54478092830704f6ea89df04cd"
|
||||
integrity sha512-vmCdO8Bm1ExT+FWfC9sd9r4jwqM7o97gGy2WBshkkXbf/2nLAJQUrZfIhw27yVOtLUev6kSZc4cav/46KbDd8A==
|
||||
|
||||
vscode-nls@^4.0.0:
|
||||
version "4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user