-
Notifications
You must be signed in to change notification settings - Fork 281
refactored output.py to correct vim behavior #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
|
@@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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': | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note to self -- we lost the |
||
| firstFilePath, firstLineNum = filesAndLineNumbers[0] | ||
| cmd += ' +%d %s' % (firstLineNum, firstFilePath) | ||
| for (filePath, lineNum) in filesAndLineNumbers[1:]: | ||
| cmd += ' +"vsp +%d %s"' % (lineNum, filePath) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woahhh so |
||
| 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): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is
czfin trunk and was changed recently. you probably reverted this in some kind of rebase or something -- mind dropping the change to this file?