@@ -319,7 +319,7 @@ def sort_key(file_info: FileInfo) -> tuple[int, str]:
319319 results .sort (key = sort_key )
320320 return results [:limit ]
321321
322- def open_in_editor (self , path : str ) -> bool :
322+ def open_in_editor (self , path : str , line_number : int | None ) -> bool :
323323 try :
324324 # First try to get editor from environment variable
325325 editor = os .environ .get ("EDITOR" )
@@ -328,9 +328,17 @@ def open_in_editor(self, path: str) -> bool:
328328 # otherwise it silently opens the terminal in the same window that is
329329 # running marimo.
330330 if editor and not _is_terminal_editor (editor ):
331+ args = (
332+ [path ]
333+ if line_number is None
334+ else editor_open_file_in_line_args (
335+ editor , path , line_number
336+ )
337+ )
338+
331339 try :
332340 # For GUI editors
333- subprocess .run ([editor , path ])
341+ subprocess .run ([editor , * args ])
334342 return True
335343 except Exception as e :
336344 LOGGER .error (f"Error opening with EDITOR: { e } " )
@@ -350,6 +358,17 @@ def open_in_editor(self, path: str) -> bool:
350358 return False
351359
352360
361+ def editor_open_file_in_line_args (
362+ editor : str , path : str , line_number : int
363+ ) -> list [str ]:
364+ if editor == "code" :
365+ return ["--goto" , f"{ path } :{ line_number } " ]
366+ elif editor == "subl" :
367+ return [f"{ path } :{ line_number } " ]
368+ else :
369+ return [f"+{ line_number } " , path ]
370+
371+
353372def natural_sort_file (file : FileInfo ) -> list [Union [int , str ]]:
354373 return natural_sort (file .name )
355374
0 commit comments