I need to implement a custom git merge bash, and I want it like VS Code’s ‘accept both’ function. Does VS Code use some utils or AST parse tool?
Hope someone can tell me some ideas, I need to implement the ‘accept both’ function in my custom git merge driver bash
What you want is to trace merge-conflict.accept.both
in https://github.com/microsoft/vscode/blob/main/extensions/merge-conflict/src/commandHandler.ts. It will lead you to applyEdit
in https://github.com/microsoft/vscode/blob/main/extensions/merge-conflict/src/documentMergeConflict.ts, which seems to just do a simple concatenation. As for how it gets the current and incoming text, see getConflictsOrEmpty
in https://github.com/microsoft/vscode/blob/main/extensions/merge-conflict/src/documentTracker.ts, which points to scanDocument
in https://github.com/microsoft/vscode/blob/main/extensions/merge-conflict/src/mergeConflictParser.ts (I.e. it parses the stuff out from the document).