Browse Source

fixup! Add jump to last/next cursor position in cdb (#140) (#143)

Leonardo Jeanteur 4 years ago
parent
commit
7f55ce2af7
2 changed files with 14 additions and 12 deletions
  1. 4 4
      hide/comp/cdb/Cell.hx
  2. 10 8
      hide/comp/cdb/Editor.hx

+ 4 - 4
hide/comp/cdb/Cell.hx

@@ -39,10 +39,6 @@ class Cell extends Component {
 		if( column.kind == Script ) root.addClass("t_script");
 		if( column.kind == Script ) root.addClass("t_script");
 		refresh();
 		refresh();
 
 
-		root.click(function(e) {
-			editor.cursor.clickCell(this, e.shiftKey);
-			e.stopPropagation();
-		});
 		switch( column.type ) {
 		switch( column.type ) {
 		case TList, TProperties:
 		case TList, TProperties:
 			element.click(function(e) {
 			element.click(function(e) {
@@ -58,6 +54,10 @@ class Cell extends Component {
 			else
 			else
 				root.addClass("t_readonly");
 				root.addClass("t_readonly");
 		}
 		}
+		root.click(function(e) {
+			editor.cursor.clickCell(this, e.shiftKey);
+			e.stopPropagation();
+		});
 
 
 		root.contextmenu(function(e) {
 		root.contextmenu(function(e) {
 			showMenu();
 			showMenu();

+ 10 - 8
hide/comp/cdb/Editor.hx

@@ -95,10 +95,12 @@ class Editor extends Component {
 		});
 		});
 		element.contextmenu(function(e) e.preventDefault());
 		element.contextmenu(function(e) e.preventDefault());
 
 
-		if( cdbTable != null )
-			cdbTable.element.mousedown(onMouseDown);
-		else
+		if( cdbTable == null )
 			element.mousedown(onMouseDown);
 			element.mousedown(onMouseDown);
+		else {
+			cdbTable.element.off("mousedown", onMouseDown);
+			cdbTable.element.mousedown(onMouseDown);
+		}
 
 
 		keys = new hide.ui.Keys(element);
 		keys = new hide.ui.Keys(element);
 		keys.addListener(onKey);
 		keys.addListener(onKey);
@@ -592,12 +594,10 @@ class Editor extends Component {
 		}
 		}
 
 
 		if( cursorIndex < cursorStates.length - 1 && cursorIndex >= 0 ) {
 		if( cursorIndex < cursorStates.length - 1 && cursorIndex >= 0 ) {
-			if( stateBehind != null && !undoStatesEqual(state, stateBehind, false) ) {
-				cursorStates.splice(cursorIndex + 1, cursorStates.length);
-			}
+			cursorStates.splice(cursorIndex + 1, cursorStates.length);
 		}
 		}
 
 
-		cursorStates.insert(cursorIndex + 1, state);
+		cursorStates.push(state);
 		if( cursorIndex < cursorStates.length - 1 )
 		if( cursorIndex < cursorStates.length - 1 )
 			cursorIndex++;
 			cursorIndex++;
 	}
 	}
@@ -607,7 +607,9 @@ class Editor extends Component {
 
 
 		if( (back && cursorIndex <= 0) || (!back && cursorIndex >= cursorStates.length - 1) )
 		if( (back && cursorIndex <= 0) || (!back && cursorIndex >= cursorStates.length - 1) )
 			return;
 			return;
-		pushCursorState();
+		if( back && cursorIndex == cursorStates.length - 1)
+			pushCursorState();
+
 		if(back)
 		if(back)
 			cursorIndex--;
 			cursorIndex--;
 		else
 		else