From 4fac68fb95d845ab8c6fdf3edba2e6c53f33111f Mon Sep 17 00:00:00 2001 From: IdanArye Date: Tue, 25 Sep 2018 02:08:25 +0300 Subject: [PATCH] Fix formatting --- autoload/vebugger/util.vim | 205 +++++++++++++++++++------------------ 1 file changed, 104 insertions(+), 101 deletions(-) diff --git a/autoload/vebugger/util.vim b/autoload/vebugger/util.vim index 4d1212f..61bfca6 100644 --- a/autoload/vebugger/util.vim +++ b/autoload/vebugger/util.vim @@ -1,127 +1,127 @@ "Returns the visually selected text function! vebugger#util#get_visual_selection() - "Shamefully stolen from http://stackoverflow.com/a/6271254/794380 - " Why is this not a built-in Vim script function?! - let [lnum1, col1] = getpos("'<")[1:2] - let [lnum2, col2] = getpos("'>")[1:2] - let lines = getline(lnum1, lnum2) - let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] - let lines[0] = lines[0][col1 - 1:] - return join(lines, "\n") + "Shamefully stolen from http://stackoverflow.com/a/6271254/794380 + " Why is this not a built-in Vim script function?! + let [lnum1, col1] = getpos("'<")[1:2] + let [lnum2, col2] = getpos("'>")[1:2] + let lines = getline(lnum1, lnum2) + let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] + let lines[0] = lines[0][col1 - 1:] + return join(lines, "\n") endfunction "Prompts the user with a filtered list of process, and returns the process id "the user selects function! vebugger#util#selectProcessOfFile(ofFile) - let l:fileName=fnamemodify(a:ofFile,':t') - if has('win32') - "Get the process data in CSV format - let l:resultLines=split(vimproc#system('tasklist /FO csv /FI "IMAGENAME eq '.l:fileName.'"'),'\r\n\|\n\|\r') + let l:fileName=fnamemodify(a:ofFile,':t') + if has('win32') + "Get the process data in CSV format + let l:resultLines=split(vimproc#system('tasklist /FO csv /FI "IMAGENAME eq '.l:fileName.'"'),'\r\n\|\n\|\r') - if l:resultLines[0]=~'\V\^INFO:' - throw 'No matching process found' - endif - "Parse(sort of) the CSV: - let l:resultLinesParsed=map(l:resultLines,'eval("[".v:val."]")') - let l:resultLinesParsed[0][2]='Session' - "Format for output - let l:linesForPrinting=map(copy(l:resultLinesParsed),'v:val[1]."\t".v:val[2]."\t\t".v:val[0]') - else - let l:resultLines=split(vimproc#system('ps -o pid,user,comm,start,state,tt -C '.fnameescape(l:fileName)),'\r\n\|\n\|\r') - let l:linesForPrinting=copy(l:resultLines) - endif + if l:resultLines[0]=~'\V\^INFO:' + throw 'No matching process found' + endif + "Parse(sort of) the CSV: + let l:resultLinesParsed=map(l:resultLines,'eval("[".v:val."]")') + let l:resultLinesParsed[0][2]='Session' + "Format for output + let l:linesForPrinting=map(copy(l:resultLinesParsed),'v:val[1]."\t".v:val[2]."\t\t".v:val[0]') + else + let l:resultLines=split(vimproc#system('ps -o pid,user,comm,start,state,tt -C '.fnameescape(l:fileName)),'\r\n\|\n\|\r') + let l:linesForPrinting=copy(l:resultLines) + endif - if len(l:linesForPrinting)<=1 - throw 'No matching process found' - endif - if &lines