File tree Expand file tree Collapse file tree 5 files changed +41
-39
lines changed
Expand file tree Collapse file tree 5 files changed +41
-39
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,11 @@ import Anser from "anser";
88
99import History from "./result-view/history" ;
1010import ScrollList from "./result-view/list" ;
11- import { OUTPUT_AREA_URI } from "./../utils" ;
11+ import { OUTPUT_AREA_URI , EmptyMessage } from "./../utils" ;
1212
1313import typeof store from "../store" ;
1414import type { IObservableValue } from "mobx" ;
1515
16- const EmptyMessage = ( ) => {
17- return (
18- < ul className = "background-message centered" >
19- < li > No output to display</ li >
20- </ ul >
21- ) ;
22- } ;
23-
2416@observer
2517class OutputArea extends React . Component < { store : store } > {
2618 showHistory : IObservableValue < boolean > = observable ( true ) ;
Original file line number Diff line number Diff line change @@ -5,16 +5,21 @@ import React from "react";
55import { observer } from "mobx-react" ;
66
77import Watch from "./watch" ;
8- import { WATCHES_URI } from "../../utils" ;
8+ import { WATCHES_URI , EmptyMessage } from "../../utils" ;
99
1010import type Kernel from "./../../kernel" ;
1111import typeof store from "../../store" ;
1212
1313const Watches = observer ( ( { store : { kernel } } : { store : store } ) => {
1414 if ( ! kernel ) {
15- atom . workspace . hide ( WATCHES_URI ) ;
16- return null ;
15+ if ( atom . config . get ( "Hydrogen.outputAreaDock" ) ) {
16+ return < EmptyMessage /> ;
17+ } else {
18+ atom . workspace . hide ( WATCHES_URI ) ;
19+ return null ;
20+ }
1721 }
22+
1823 return (
1924 < div className = "sidebar watch-sidebar" >
2025 { kernel . watchesStore . watches . map ( watch => (
Original file line number Diff line number Diff line change @@ -100,11 +100,18 @@ const Config = {
100100 default : "{}"
101101 } ,
102102 outputAreaDock : {
103- title : "Output Area Dock " ,
103+ title : "Leave output dock open " ,
104104 description :
105105 "Do not close dock when switching to an editor without a running kernel" ,
106106 type : "boolean" ,
107107 default : false
108+ } ,
109+ outputAreaDefault : {
110+ title : "View output in the dock by default" ,
111+ description :
112+ "If enabled, output will be displayed in the dock by default rather than inline" ,
113+ type : "boolean" ,
114+ default : false
108115 }
109116 }
110117} ;
Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ import AutocompleteProvider from "./autocomplete-provider";
4040import HydrogenProvider from "./plugin-api/hydrogen-provider" ;
4141import {
4242 log ,
43- focus ,
4443 reactFactory ,
4544 isMultilanguageGrammar ,
4645 renderDevTools ,
@@ -349,11 +348,11 @@ const Hydrogen = {
349348 kernel . watchesStore . run ( ) ;
350349 return ;
351350 }
352- const globalOutputStore = atom . workspace
353- . getPaneItems ( )
354- . find ( item => item instanceof OutputPane )
355- ? kernel . outputStore
356- : null ;
351+ const globalOutputStore =
352+ atom . config . get ( "Hydrogen.outputAreaDefault" ) ||
353+ atom . workspace . getPaneItems ( ) . find ( item => item instanceof OutputPane )
354+ ? kernel . outputStore
355+ : null ;
357356
358357 const { outputStore } = new ResultView (
359358 store . markers ,
@@ -367,18 +366,7 @@ const Hydrogen = {
367366 outputStore . appendOutput ( result ) ;
368367 if ( globalOutputStore ) {
369368 globalOutputStore . appendOutput ( result ) ;
370-
371- if ( store . kernel !== kernel ) return ;
372-
373- const container = atom . workspace . paneContainerForURI ( OUTPUT_AREA_URI ) ;
374- const pane = atom . workspace . paneForURI ( OUTPUT_AREA_URI ) ;
375- if (
376- ( container && container . isVisible && ! container . isVisible ( ) ) ||
377- ( pane && pane . itemForURI ( OUTPUT_AREA_URI ) !== pane . getActiveItem ( ) )
378- ) {
379- await atom . workspace . open ( OUTPUT_AREA_URI , { searchAllPanes : true } ) ;
380- focus ( store . editor ) ;
381- }
369+ openOrShowDock ( OUTPUT_AREA_URI ) ;
382370 }
383371 } ) ;
384372 } ,
Original file line number Diff line number Diff line change @@ -38,19 +38,21 @@ export function focus(item: ?mixed) {
3838 }
3939}
4040
41- export function openOrShowDock ( URI : string ) {
41+ export async function openOrShowDock ( URI : string ) : Promise < ? void > {
4242 // atom.workspace.open(URI) will activate/focus the dock by default
4343 // dock.toggle() or dock.show() will leave focus wherever it was
4444
4545 // this function is basically workspace.open, except it
46- // will not focus the pane if there is an open instance of that view
46+ // will not focus the newly opened pane
47+ let dock = atom . workspace . paneContainerForURI ( URI ) ;
48+ if ( dock ) return dock . show ( ) ;
4749
48- const dock = atom . workspace . paneContainerForURI ( URI ) ;
49- if ( ! dock ) {
50- atom . workspace . open ( URI , { searchAllPanes : true } ) ;
51- } else {
52- dock . show ( ) ;
53- }
50+ await atom . workspace . open ( URI , {
51+ searchAllPanes : true ,
52+ activatePane : false
53+ } ) ;
54+ dock = atom . workspace . paneContainerForURI ( URI ) ;
55+ return dock ? dock . show ( ) : null ;
5456}
5557
5658export function grammarToLanguage ( grammar : ?atom$Grammar ) {
@@ -216,3 +218,11 @@ export function rowRangeForCodeFoldAtBufferRow(
216218 return range ? [ range . start . row , range . end . row ] : null ;
217219 }
218220}
221+
222+ export const EmptyMessage = ( ) => {
223+ return (
224+ < ul className = "background-message centered" >
225+ < li > No output to display</ li >
226+ </ ul >
227+ ) ;
228+ } ;
You can’t perform that action at this time.
0 commit comments