Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/makeDist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VERSION="$(python ./src/version.py)"
DEST="./dist/fpp.$VERSION.tar.gz"
mkdir -p ./dist/
tar -cf $DEST src/*.py fpp
tar -czf $DEST src/*.py fpp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is czf in trunk and was changed recently. you probably reverted this in some kind of rebase or something -- mind dropping the change to this file?


sed -i '' -e "s#url .*#url \"https://github.com/facebook/PathPicker/releases/download/$VERSION/fpp.$VERSION.tar.gz\"#g" ./fpp.rb
HASH=$(cat $DEST | shasum -a 256 | cut -d " " -f 1)
Expand Down
49 changes: 25 additions & 24 deletions src/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ def execComposedCommand(command, lineObjs):


def editFiles(lineObjs):
partialCommands = []
logger.addEvent('editing_num_files', len(lineObjs))
for lineObj in lineObjs:
(path, num) = (lineObj.getPath(), lineObj.getLineNum())
partialCommands.append(getEditFileCommand(path, num))
command = joinEditCommands(partialCommands)
filesAndLineNumbers = [(lineObj.getPath(), lineObj.getLineNum())
for lineObj in lineObjs]
command = joinFilesIntoCommand(filesAndLineNumbers)
appendIfInvalid(lineObjs)
appendToFile(command)
appendExit()
Expand Down Expand Up @@ -94,33 +92,36 @@ def getEditorAndPath():
return 'vim', 'vim'


def getEditFileCommand(filePath, lineNum):
editor, _editor_path = getEditorAndPath()
if editor in ['vim', 'vim -p'] and lineNum != 0:
return '\'%s\' +%d' % (filePath, lineNum)
elif editor in ['vi', 'nvim', 'nano', 'joe', 'emacs',
'emacsclient'] and lineNum != 0:
return '+%d \'%s\'' % (lineNum, filePath)
elif editor in ['subl', 'sublime', 'atom'] and lineNum != 0:
return '\'%s:%d\'' % (filePath, lineNum)
else:
return "'%s'" % filePath


def expandPath(filePath):
# expand ~/ paths
filePath = os.path.expanduser(filePath)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see why this had to go -- yeah you didnt have global context when composing these mini-parts.

# and in case of grep, expand ./ as well
return os.path.abspath(filePath)


def joinEditCommands(partialCommands):
def joinFilesIntoCommand(filesAndLineNumbers):
editor, editor_path = getEditorAndPath()
if editor in ['vim', 'mvim'] and \
not os.environ.get('FPP_DISABLE_SPLIT'):
return editor_path + ' -O ' + ' '.join(partialCommands)
# Assume that all other editors behave like emacs
return editor_path + ' ' + ' '.join(partialCommands)
cmd = editor_path + ' '
if editor == 'vim -p':
firstFilePath, firstLineNum = filesAndLineNumbers[0]
cmd += ' +%d %s' % (firstLineNum, firstFilePath)
for (filePath, lineNum) in filesAndLineNumbers[1:]:
cmd += ' +"tabnew +%d %s"' % (lineNum, filePath)
elif editor == 'vim':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self -- we lost the FPP_DISABLE_SPLIT behavior here so lets add that back

firstFilePath, firstLineNum = filesAndLineNumbers[0]
cmd += ' +%d %s' % (firstLineNum, firstFilePath)
for (filePath, lineNum) in filesAndLineNumbers[1:]:
cmd += ' +"vsp +%d %s"' % (lineNum, filePath)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woahhh so vsp does vertical split like -O and allows you to specify the line numbers? very cool!

else:
for (filePath, lineNum) in filesAndLineNumbers:
if editor in ['vi', 'nvim', 'nano', 'joe', 'emacs',
'emacsclient'] and lineNum != 0:
cmd += ' +%d \'%s\'' % (lineNum, filePath)
elif editor in ['subl', 'sublime', 'atom'] and lineNum != 0:
cmd += ' \'%s:%d\'' % (filePath, lineNum)
else:
cmd += " '%s'" % filePath
return cmd


def composeCdCommand(command, lineObjs):
Expand Down