mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Port of Maddy's Edit Data Line Fix (#10676)
This commit is contained in:
@@ -66,6 +66,7 @@ export class EditDataGridPanel extends GridParentComponent {
|
|||||||
private rowIdMappings: { [gridRowId: number]: number } = {};
|
private rowIdMappings: { [gridRowId: number]: number } = {};
|
||||||
private dirtyCells: number[] = [];
|
private dirtyCells: number[] = [];
|
||||||
protected plugins = new Array<Slick.Plugin<any>>();
|
protected plugins = new Array<Slick.Plugin<any>>();
|
||||||
|
private newlinePattern: string;
|
||||||
// List of column names with their indexes stored.
|
// List of column names with their indexes stored.
|
||||||
private columnNameToIndex: { [columnNumber: number]: string } = {};
|
private columnNameToIndex: { [columnNumber: number]: string } = {};
|
||||||
// Edit Data functions
|
// Edit Data functions
|
||||||
@@ -190,10 +191,10 @@ export class EditDataGridPanel extends GridParentComponent {
|
|||||||
returnVal = null;
|
returnVal = null;
|
||||||
}
|
}
|
||||||
else if (Services.DBCellValue.isDBCellValue(value)) {
|
else if (Services.DBCellValue.isDBCellValue(value)) {
|
||||||
returnVal = this.spacefyLinebreaks(value.displayValue);
|
returnVal = this.replaceLinebreaks(value.displayValue);
|
||||||
}
|
}
|
||||||
else if (typeof value === 'string') {
|
else if (typeof value === 'string') {
|
||||||
returnVal = this.spacefyLinebreaks(value);
|
returnVal = this.replaceLinebreaks(value);
|
||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
};
|
};
|
||||||
@@ -431,8 +432,12 @@ export class EditDataGridPanel extends GridParentComponent {
|
|||||||
/**
|
/**
|
||||||
* Replace the line breaks with space.
|
* Replace the line breaks with space.
|
||||||
*/
|
*/
|
||||||
private spacefyLinebreaks(inputStr: string): string {
|
private replaceLinebreaks(inputStr: string): string {
|
||||||
return inputStr.replace(/(\r\n|\n|\r)/g, ' ');
|
let newlineMatches = inputStr.match(/(\r\n|\n|\r)/g);
|
||||||
|
if (newlineMatches && newlineMatches.length > 0) {
|
||||||
|
this.newlinePattern = newlineMatches[0];
|
||||||
|
}
|
||||||
|
return inputStr.replace(/(\r\n|\n|\r)/g, '\u0000');
|
||||||
}
|
}
|
||||||
|
|
||||||
private refreshGrid(): Thenable<void> {
|
private refreshGrid(): Thenable<void> {
|
||||||
@@ -575,7 +580,7 @@ export class EditDataGridPanel extends GridParentComponent {
|
|||||||
? self.rowIdMappings[self.currentCell.row]
|
? self.rowIdMappings[self.currentCell.row]
|
||||||
: self.currentCell.row;
|
: self.currentCell.row;
|
||||||
|
|
||||||
return self.dataService.updateCell(sessionRowId, self.currentCell.column - 1, self.currentEditCellValue);
|
return self.dataService.updateCell(sessionRowId, self.currentCell.column - 1, this.newlinePattern ? self.currentEditCellValue.replace('\u0000', this.newlinePattern) : self.currentEditCellValue);
|
||||||
}).then(
|
}).then(
|
||||||
result => {
|
result => {
|
||||||
self.currentEditCellValue = undefined;
|
self.currentEditCellValue = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user