diff --git a/src/sql/workbench/parts/grid/views/editData/editData.component.ts b/src/sql/workbench/parts/grid/views/editData/editData.component.ts index 5a65e9be5d..567b43e1f9 100644 --- a/src/sql/workbench/parts/grid/views/editData/editData.component.ts +++ b/src/sql/workbench/parts/grid/views/editData/editData.component.ts @@ -177,10 +177,12 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On this.overrideCellFn = (rowNumber, columnId, value?, data?): string => { let returnVal = ''; + // replace the line breaks with space since the edit text control cannot + // render line breaks and strips them, updating the value. if (Services.DBCellValue.isDBCellValue(value)) { - returnVal = value.displayValue; + returnVal = this.spacefyLinebreaks(value.displayValue); } else if (typeof value === 'string') { - returnVal = value; + returnVal = this.spacefyLinebreaks(value); } return returnVal; }; @@ -406,6 +408,13 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On this.refreshGrid(); } + /** + * Replace the line breaks with space. + */ + private spacefyLinebreaks(inputStr: string): string { + return inputStr.replace(/(\r\n|\n|\r)/g, ' '); + } + private refreshGrid(): Thenable { return new Promise((resolve, reject) => { const self = this;