1212 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 
1313 * 
1414 */ 
15- import   *   as   vscode   from   "vscode" ; 
15+ 
1616import  {  commands ,  window ,  workspace ,  TextDocument ,  ViewColumn  }  from  "vscode" ; 
17- import  *  as  path  from  'path' ; 
1817import  *  as  quarto  from  "quarto-core" ; 
19- import  fs  from  "node:fs" ; 
20- import  yaml  from  "js-yaml" ; 
2118import  {  Command  }  from  "../../core/command" ; 
2219import  {  isQuartoDoc ,  kQuartoLanguageId  }  from  "../../core/doc" ; 
2320import  {  VisualEditorProvider  }  from  "./editor" ; 
@@ -27,10 +24,10 @@ export function determineMode(doc: TextDocument): string | undefined {
2724  const  text  =  doc . getText ( ) ; 
2825  // check if file itself has a mode 
2926  if  ( hasEditorMode ( text ,  "source" ) )  { 
30-     editorOpener  =  "source " ; 
27+     editorOpener  =  "textEditor " ; 
3128  } 
3229  else  if  ( hasEditorMode ( text ,  "visual" ) )  { 
33-     editorOpener  =  "visual" ; 
30+     editorOpener  =  VisualEditorProvider . viewType ; 
3431  } 
3532  // check if has a _quarto.yml or _quarto.yaml file with editor specified 
3633  else  { 
@@ -40,16 +37,6 @@ export function determineMode(doc: TextDocument): string | undefined {
4037  return  editorOpener ; 
4138} 
4239
43- export  async  function  setEditorOpener ( )  { 
44-   const  config  =  vscode . workspace . getConfiguration ( 'quarto' ) . get < string > ( 'defaultEditor' ) ; 
45-   const  viewType  =  config  ===  'visual'  ? VisualEditorProvider . viewType  : 'textEditor' ; 
46- 
47-   await  vscode . commands . executeCommand ( "workbench.action.setDefaultEditor" , 
48-     '*.qmd' , 
49-     viewType 
50-   ) ; 
51- } 
52- 
5340export  function  modeFromQuartoYaml ( doc : TextDocument ) : string  |  undefined  { 
5441  const  metadataFiles  =  quarto . metadataFilesForDocument ( doc . uri . fsPath ) ; 
5542  if  ( ! metadataFiles )  { 
@@ -58,8 +45,11 @@ export function modeFromQuartoYaml(doc: TextDocument): string | undefined {
5845  if  ( metadataFiles )  { 
5946    for  ( const  metadataFile  of  metadataFiles )  { 
6047      const  yamlText  =  quarto . yamlFromMetadataFile ( metadataFile ) ; 
61-       if  ( yamlText ?. editor  ===  "source"  ||  yamlText ?. editor  ===  "visual" )  { 
62-         return  yamlText ?. editor ; 
48+       if  ( yamlText ?. editor  ===  "source" )  { 
49+         return  "textEditor" 
50+       } 
51+       if  ( yamlText ?. editor  ===  "visual" )  { 
52+         return  VisualEditorProvider . viewType ; 
6353      } 
6454    } 
6555  } 
0 commit comments