Browse Source

fixed cdb goto Reference + cdb focus problems

Nicolas Cannasse 5 years ago
parent
commit
8ce0dbb8b8
2 changed files with 14 additions and 2 deletions
  1. 1 1
      hide/comp/cdb/Editor.hx
  2. 13 1
      hide/view/CdbTable.hx

+ 1 - 1
hide/comp/cdb/Editor.hx

@@ -477,7 +477,7 @@ class Editor extends Component {
 	}
 
 	function openReference( s : cdb.Sheet, line : Int, column : Int ) {
-		ide.open("hide.view.CdbTable", { path : s.name }, function(view) @:privateAccess Std.downcast(view,hide.view.CdbTable).editor.cursor.setDefault(line,column));
+		ide.open("hide.view.CdbTable", {}, function(view) Std.downcast(view,hide.view.CdbTable).goto(s,line,column));
 	}
 
 	public function syncSheet( ?base, ?name ) {

+ 13 - 1
hide/view/CdbTable.hx

@@ -6,6 +6,7 @@ class CdbTable extends hide.ui.View<{}> {
 	var editor : hide.comp.cdb.Editor;
 	var currentSheet : String;
 	var tabCache : String;
+	var tabs : hide.comp.Tabs;
 	var view : cdb.DiffFile.ConfigView;
 
 	public function new( ?state ) {
@@ -23,6 +24,16 @@ class CdbTable extends hide.ui.View<{}> {
 		view = cast this.config.get("cdb.view");
 	}
 
+	public function goto( s : cdb.Sheet, line : Int, column : Int ) {
+		var sheets = [for( s in getSheets() ) s.name];
+		var index = sheets.indexOf(s.name);
+		if( index < 0 ) return;
+		tabs.currentTab = tabContents[index].parent();
+		editor.cursor.setDefault(line, column);
+		editor.focus();
+		haxe.Timer.delay(() -> editor.cursor.update(), 1); // scroll
+	}
+
 	function syncTabs() {
 		if( getTabCache() != tabCache || editor.getCurrentSheet() != currentSheet ) {
 			currentSheet = editor.getCurrentSheet();
@@ -47,6 +58,7 @@ class CdbTable extends hide.ui.View<{}> {
 		editor.show(sheets[index],tabContents[index]);
 		currentSheet = editor.getCurrentSheet();
 		ide.currentConfig.set("cdb.currentSheet", sheets[index].name);
+		haxe.Timer.delay(editor.focus,1);
 	}
 
 	override function onDisplay() {
@@ -61,7 +73,7 @@ class CdbTable extends hide.ui.View<{}> {
 			return;
 		}
 		element.addClass("cdb-view");
-		var tabs = new hide.comp.Tabs(element, true);
+		tabs = new hide.comp.Tabs(element, true);
 		tabCache = getTabCache();
 		tabContents = [];
 		for( sheet in sheets ) {