Commits

ZyX_I committed f03805f

@aurum/drivers/common/utils: Made utils.run use os.readsystem() in some cases

Comments (0)

Files changed (2)

plugin/aurum/drivers/common/utils.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.0', {'@/resources': '0.0',}, 0)
+    execute frawor#Setup('0.0', {'@/resources': '0.0',
+                \                       '@/os': '0.2'}, 0)
     finish
 elseif s:_pluginloaded
     finish
 "▶1 utils.run :: sh, hasnulls::0|1|2 → [String] + shell
 function s:utils.run(cmd, hasnulls, cdpath)
     if a:hasnulls==2 && !empty(&shellredir)
-        let tempfile=tempname()
-        let etempfile=shellescape(tempfile, 1)
-        let cmd=a:cmd
-        if stridx(&shellredir, '%s')!=-1
-            let cmd.=printf(&shellredir, etempfile)
-        else
-            let cmd.=&shellredir.etempfile
-        endif
-        if !empty(a:cdpath)
-            let cmd='cd '.shellescape(a:cdpath).' && '.cmd
-        endif
-        try
-            execute 'silent! !'.cmd
-            if !filereadable(tempfile)
-                return s:utils.run(a:cmd, 1, a:cdpath)
-            endif
-            return readfile(tempfile, 'b')
-        finally
-            if filereadable(tempfile)
-                call delete(tempfile)
-            endif
-        endtry
+        return call(s:_r.os.readsystem, [a:cmd]+(empty(a:cdpath)?
+                    \                               ([]):
+                    \                               ([a:cdpath])), {})
     elseif a:hasnulls
         let savedlazyredraw=&lazyredraw
         let savedeventignore=&eventignore

plugin/aurum/log.vim

     if index(a:edges, [a:ni, a:ni-1])!=-1 || index(a:edges, [a:ni, a:ni])!=-1
         let c='|'
     endif
-    return repeat(['|', ' '], a:ni)+
-                \[c, ' ']+
-                \repeat(['|', " "], (a:n_columns-a:ni-1))
+    return repeat('| ', a:ni).c.' '.repeat('| ', (a:n_columns-a:ni-1))
 endfunction
 "▶2 glog.addlines
 function s:F.glog.addlines(special, lnum)
     endif
     let fix_nodeline_tail = (lnum<=2 && add_padding_line)
     let shift_interline=repeat(['|', ' '], idx)
-    let nodeline=copy(shift_interline)+
-                \[a:char, ' ']+
+    let nodeline=shift_interline+[a:char, ' ']+
                 \s:F.glog.get_nodeline_edges_tail(idx,     a:state[1], ncols,
                 \                                 coldiff, a:state[0],
                 \                                 fix_nodeline_tail)
     let shift_interline+=repeat([' '], n_spaces)+
                 \        repeat([edge_ch, ' '], (ncols-idx-1))
     call s:F.glog.draw_edges(edges, nodeline, shift_interline)
-    let lines=[nodeline]
-    if add_padding_line
-        call add(lines, s:F.glog.get_padding_line(idx, ncols, edges))
-    endif
+    let joined_nl=join(nodeline, '')
+    let joined_sil=join(shift_interline, '')
     if has_key(a:text, 'skip')
-        let joined_sil=join(shift_interline, '')
-        let joined_nl=join(nodeline, '')
         let a:text.text=[]
         if joined_nl!~#'\v^[*| ]+$'
             let a:text.text+=[joined_nl]
             let a:text.text+=[joined_sil]
         endif
         return a:text
-    else
-        call add(lines, shift_interline)
     endif
+    let lines=[joined_nl]
+    if add_padding_line
+        call add(lines, s:F.glog.get_padding_line(idx, ncols, edges))
+    endif
+    call add(lines, joined_sil)
     let ltdiff=lnum-len(lines)
     if ltdiff>0
-        let extra_interline=repeat(['|', ' '], ncols+coldiff)
-        call extend(lines, repeat([extra_interline], ltdiff))
+        let extra_interline=repeat('| ', ncols+coldiff)
+        let lines+=repeat([extra_interline], ltdiff)
     else
         call extend(a:text.text, repeat([''], -ltdiff))
     endif
     let indentation_level=2*max([ncols, ncols+coldiff])
     let a:state[0]=coldiff
     let a:state[1]=idx
-    call map(lines, 'printf("%-*s ", indentation_level, join(v:val, ""))')
+    call map(lines, 'printf("%-*s ", indentation_level, v:val)')
     let curspecial=a:text.special
     let shiftlen=len(lines[0])
     call s:F.glog.addcols(a:text.special, shiftlen)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.