2
0
Эх сурвалжийг харах

[cdb] Copy just cell content if only one cell is selected

Clément Espeute 11 сар өмнө
parent
commit
946375ad58
1 өөрчлөгдсөн 19 нэмэгдсэн , 6 устгасан
  1. 19 6
      hide/comp/cdb/Editor.hx

+ 19 - 6
hide/comp/cdb/Editor.hx

@@ -445,12 +445,25 @@ class Editor extends Component {
 			}
 			schema = [for( x in sel.x1...sel.x2+1 ) cursor.table.columns[x]];
 		}
-		clipboard = {
-			data : data,
-			text : Std.string([for( o in data ) cursor.table.sheet.objToString(o,true)]),
-			schema : schema,
-		};
-		ide.setClipboard(clipboard.text);
+
+		// In case we only have one value, just copy the cell value
+		if (data.length == 1 && Reflect.fields(data[0]).length == 1) {
+			var colName = Reflect.fields(data[0])[0];
+			var col = cursor.table.columns.find((c) -> c.name == colName);
+			if (col == null)
+				throw "unknown column";
+			var str = cursor.table.sheet.colToString(col, Reflect.field(data[0], colName) ,true);
+			ide.setClipboard(str);
+		}
+		// copy many values at once
+		else {
+			clipboard = {
+				data : data,
+				text : Std.string([for( o in data ) cursor.table.sheet.objToString(o,true)]),
+				schema : schema,
+			};
+			ide.setClipboard(clipboard.text);
+		}
 	}
 
 	function stringToCol(str : String) : Null<Int> {