* Inserts the debug configuration into the document. * Invokes the document formatter to ensure JSON is formatted nicely. * @param {TextDocument} document * @param {Position} position * @param {DebugConfiguration} config * @returns {Promise } * @memberof LaunchJsonCompletionIt
(
document: vscode.TextDocument,
position: vscode.Position,
config: vscode.DebugConfiguration,
)
| 44 | * @memberof LaunchJsonCompletionItemProvider |
| 45 | */ |
| 46 | public static async insertDebugConfiguration( |
| 47 | document: vscode.TextDocument, |
| 48 | position: vscode.Position, |
| 49 | config: vscode.DebugConfiguration, |
| 50 | ): Promise<void> { |
| 51 | const cursorPosition = LaunchJsonUpdaterHelper.getCursorPositionInConfigurationsArray( |
| 52 | document, |
| 53 | position, |
| 54 | ); |
| 55 | if (!cursorPosition) { |
| 56 | return; |
| 57 | } |
| 58 | const commaPosition = LaunchJsonUpdaterHelper.isCommaImmediatelyBeforeCursor(document, position) |
| 59 | ? 'BeforeCursor' |
| 60 | : undefined; |
| 61 | const formattedJson = LaunchJsonUpdaterHelper.getTextForInsertion( |
| 62 | config, |
| 63 | cursorPosition, |
| 64 | commaPosition, |
| 65 | ); |
| 66 | const workspaceEdit = new vscode.WorkspaceEdit(); |
| 67 | workspaceEdit.insert(document.uri, position, formattedJson); |
| 68 | await vscode.workspace.applyEdit(workspaceEdit); |
| 69 | Promise.resolve(vscode.commands.executeCommand('editor.action.formatDocument')).then(() => { |
| 70 | // noop |
| 71 | }); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Gets the string representation of the debug config for insertion in the document. |
nothing calls this directly
no test coverage detected