File tree Expand file tree Collapse file tree 2 files changed +77
-8
lines changed Expand file tree Collapse file tree 2 files changed +77
-8
lines changed Original file line number Diff line number Diff line change @@ -238,9 +238,9 @@ def expand(sconf, cwd=None):
238238 )
239239 )
240240 ):
241- p = sconf ['panes' ][p_index ] = {
242- 'shell_command' : []
243- }
241+ p = sconf ['panes' ][p_index ] = {
242+ 'shell_command' : []
243+ }
244244
245245 sconf ['panes' ] = [expand (pane ) for pane in sconf ['panes' ]]
246246
@@ -292,18 +292,18 @@ def trickle(sconf):
292292
293293 # Prepend shell_command_before to commands
294294 if 'shell_command_before' in sconf :
295- commands_before = sconf ['shell_command_before' ]
295+ commands_before . extend ( sconf ['shell_command_before' ])
296296 if 'shell_command_before' in windowconfig :
297297 commands_before .extend (windowconfig ['shell_command_before' ])
298298 if 'shell_command_before' in paneconfig :
299299 commands_before .extend (paneconfig ['shell_command_before' ])
300- if 'shell_command' not in paneconfig :
301- paneconfig ['shell_command' ] = list ()
302300
303- if paneconfig [ 'shell_command' ] :
301+ if 'shell_command' in paneconfig :
304302 commands_before .extend (paneconfig ['shell_command' ])
305303
306- paneconfig ['shell_command' ] = commands_before
304+ p_index = windowconfig ['panes' ].index (paneconfig )
305+ windowconfig ['panes' ][p_index ]['shell_command' ] = commands_before
306+ #paneconfig['shell_command'] = commands_before
307307
308308 return sconf
309309
Original file line number Diff line number Diff line change @@ -664,6 +664,75 @@ def test_shell_command_before(self):
664664 self .assertDictEqual (test_config , self .config_after )
665665
666666
667+ class ShellCommandBeforeSession (TestCase ):
668+
669+ def test_in_session_scope (self ):
670+
671+ yaml_config = """
672+ shell_command_before:
673+ - 'echo "hi"'
674+ session_name: 'test'
675+ windows:
676+ - window_name: editor
677+ panes:
678+ - shell_command:
679+ - vim
680+ - :Ex
681+ - pane
682+ - cd /usr
683+ - window_name: logging
684+ panes:
685+ - shell_command:
686+ -
687+ - shell_command:
688+ - top
689+ - emacs
690+ """
691+
692+ yaml_final_config = """
693+ shell_command_before:
694+ - 'echo "hi"'
695+ session_name: 'test'
696+ windows:
697+ - window_name: editor
698+ panes:
699+ - shell_command:
700+ - 'echo "hi"'
701+ - vim
702+ - :Ex
703+ - shell_command:
704+ - 'echo "hi"'
705+ - shell_command:
706+ - 'echo "hi"'
707+ - cd /usr
708+ - window_name: logging
709+ panes:
710+ - shell_command:
711+ - 'echo "hi"'
712+ - shell_command:
713+ - 'echo "hi"'
714+ - top
715+ - emacs
716+ """
717+
718+ self .maxDiff = None
719+
720+ sconfig = kaptan .Kaptan (handler = 'yaml' )
721+ sconfig = sconfig .import_config (yaml_config ).get ()
722+
723+ config .validate_schema (sconfig )
724+
725+ self .assertDictEqual (config .expand (sconfig ), sconfig )
726+
727+ self .assertDictEqual (
728+ config .expand (config .trickle (sconfig )),
729+ self .yaml_to_dict (yaml_final_config )
730+ )
731+
732+ def yaml_to_dict (self , yaml ):
733+ return kaptan .Kaptan (handler = 'yaml' ).import_config (yaml ).get ()
734+
735+
667736class TrickleRelativeStartDirectory (TestCase ):
668737
669738 config_expanded = { # shell_command_before is string in some areas
You can’t perform that action at this time.
0 commit comments