Skip to content
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

Replace line in buffer on jedi rename #906

Merged
merged 1 commit into from
Feb 5, 2019

Conversation

stevanmilic
Copy link
Contributor

If folds are present before the rename they will
be overwritten if folds aren't open, because
vim.current.window.cursor doesn't jump inside
the folds.

Fixes #789

@codecov-io
Copy link

codecov-io commented Feb 3, 2019

Codecov Report

Merging #906 into master will increase coverage by 2.17%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #906      +/-   ##
==========================================
+ Coverage   53.47%   55.64%   +2.17%     
==========================================
  Files           3        3              
  Lines         619      620       +1     
  Branches      122      122              
==========================================
+ Hits          331      345      +14     
+ Misses        252      243       -9     
+ Partials       36       32       -4
Flag Coverage Δ
#py27 54.51% <0%> (?)
#py36 53.38% <0%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pythonx/jedi_vim.py 59.07% <0%> (+2.2%) ⬆️
test/test_integration.py 86.66% <0%> (+4.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f367497...a4e8439. Read the comment docs.

# Open all folds in the window, so that replacing of original
# word doesn't overwrite the folded section.
vim_command('normal! zR')

# Replace original word.
vim.current.window.cursor = (r.line, r.column)
vim_command('normal! c{0:d}l{1}'.format(len(orig), replace))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should use another API to change the word instead, likely the setline() function.
This avoids (re)storing the view also.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could just set vim.current.buffer[r.line - 1] to the resulting string (where the replacement was done in/via Python).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh nice, thanks! should be solved now

@stevanmilic stevanmilic changed the title Open all folds before doing a jedi rename Replace line in buffer on jedi rename Feb 5, 2019
@blueyed
Copy link
Collaborator

blueyed commented Feb 5, 2019

Great!

CI failure is unrelated, working on fixing it in #908.

@blueyed
Copy link
Collaborator

blueyed commented Feb 5, 2019

Please rebase it on master.

@stevanmilic
Copy link
Contributor Author

done

@blueyed blueyed merged commit ba5915b into davidhalter:master Feb 5, 2019
@blueyed
Copy link
Collaborator

blueyed commented Feb 5, 2019

Thank you!

blueyed added a commit to blueyed/jedi-vim that referenced this pull request Aug 11, 2019
    * pythonx/jedi 60415033...35e5cf2c (106):
      > A small Changelog improvement
      > Cleanup Changelog for the next release
      > Make it possible to access functions that were inherited, see #1347
      > Messed up a Windows test
      > Again a small windows issue fixed.
      > Need to escape the path backslash for windows slashes
      > Make it possible to access properties again
      > A small compatibility fix
      > Fix an issue with type vars that might have been a problem for other things as well
      > Don't add quotes after paths if they are already there
      > A small speed optimization that helps a lot with sys.version_info >= (3, 0) patterns in typeshed
      > Remove an unnecessary isinstance usage
      > Make CompiledValue lazy
      > A python 2 fix
      > Fix an error that occured because of some refactorings
      > Fix one more os.path.join issue
      > Fix more issues with os.path path completion
      > Make join detection much easier
      > Fix some remaining issues with file path completions
      > A few more tests for path completions (join)
      > Fix quote completions for os.path.join path completions
      > Fix first param argument of os.path.join file completions
      > Fix arglist/trailer issues
      > in os.path.join completions, directories should not end in a slash
      > Make some file path completions in os.path.join work
      > Fix os.path.join static value gathering
      > os.path.sep should always have a clear value
      > Fix string name completion for stuff like dirname and abspath
      > Fix bytes issue with file path adding
      > Python 2 compatibility
      > Make __file__ return the correct value
      > Fix string additions when used in certain ways
      > Make string additions work for file path completion
      > Fix interpeter project path
      > Fix the REPL completer for file path completions
      > Fix a few more file name completion cases
      > A first iteration for file path completions
      > Fix a test failure
      > Add Definition.execute, fixes davidhalter#1076
      > Add tests to show that davidhalter#516 is not working, yet
      > List possible Definition.type in its docstring, fixes davidhalter#1069.
      > Start writing the Changelog for 0.15.0
      > 3.8-dev should not be allowed to fail
      > Skip more Python 2 tests
      > Skipping of tests was done the wrong way again
      > Skip the right tests
      > Parameter.kind is not avaialble in Python 3.5
      > Fix Python 2 test issues
      > Add a few docstrings to make some things clearer
      > Add ParamDefinition.kind, fixes #1361
      > Make it possible to format a param to a string, fixes davidhalter#1074
      > Add another test for signature annotations
      > Add Signature.to_string() with proper tests, fixes davidhalter#779, fixes davidhalter#780
      > Test infer_default
      > Use a helper to create definitions
      > Add a execute_annotation option to infer_annotation
      > Test infer_annotation
      > Make it possible for users to infer annotations/defaults
      > A first iteration of adding signatures to the API, fixes #1139
      > Fix a caching issue
      > Forgot the right resolve_stars parameters in one place
      > Cache getting resolved param names
      > Turn around resolve_stars, it shouldn't by default be resolved
      > Remove a class that is not needed anymore
      > Revert "Use __str__ instead of to_string"
      > Fix the last remaining issues with function signature
      > overloaded_functions should be private
      > Use __str__ instead of to_string
      > Better repr for CallSignature
      > Fix some minor signature issues
      > Remove the unused function signature_matches
      > Fix signatures for __init__ calls when used with supers, fixes #1163
      > Fix some issues for args resolving in method calls
      > Remove a bit of code that i sprobably unused
      > Move get_signatures from Function to FunctionMixin
      > Merge the signature changes
      > Remove an import
      > Small refactoring
      > Skipped Python 2 Interpreter tests the wrong way
      > Remove a paragraph in docs that was arguing that stubs and generics (and other things) were not properly supported, fixes davidhalter#1012
      > Fix partial signatures for MixedObject
      > Fix partial signatures, fixes #1371
      > Make sure with a test that the staticmethod signature is also correct
      > Fix classmethod signature, fixes davidhalter#498
      > Deal with annotation on *args and **kwargs correctly, fixes davidhalter#980
      > Use LazyContextWrapper more
      > Very small refactoring
      > Fix for failing assertion on native modules Issue #1354 (#1370)
      > Skip numpydoc tests for Python 2
      > Remove code that didn't mean anything
      > Fix docstrings for wrapped functions, fixes davidhalter#906
      > Fix an isue about dict ordering in Python before 3.6.
      > Make it clearer when get_param is used.
      > A small dataclass refactoring
      > Evaluate annotations for dataclasses when infer is called on param
      > Get inheritance of dataclass right
      > A first working iteration of dataclass signatures, fixes #1213
      > Remove an unused function
      > Dataclass progress
      > Add enum changes to changelog
      > Fix a recursion error about getting metaclasses
      > One test about recursion issues only applied to Python 2
      > Use class filters in instances differently so metaclass plugins work, fixes davidhalter#1090
      > First step in working with metaclasses in plugins, see davidhalter#1090.
      > Refactor the plugin registry
      > Remove classes from plugins and use decorators instead
davidhalter pushed a commit that referenced this pull request Aug 11, 2019
    * pythonx/jedi 60415033...35e5cf2c (106):
      > A small Changelog improvement
      > Cleanup Changelog for the next release
      > Make it possible to access functions that were inherited, see #1347
      > Messed up a Windows test
      > Again a small windows issue fixed.
      > Need to escape the path backslash for windows slashes
      > Make it possible to access properties again
      > A small compatibility fix
      > Fix an issue with type vars that might have been a problem for other things as well
      > Don't add quotes after paths if they are already there
      > A small speed optimization that helps a lot with sys.version_info >= (3, 0) patterns in typeshed
      > Remove an unnecessary isinstance usage
      > Make CompiledValue lazy
      > A python 2 fix
      > Fix an error that occured because of some refactorings
      > Fix one more os.path.join issue
      > Fix more issues with os.path path completion
      > Make join detection much easier
      > Fix some remaining issues with file path completions
      > A few more tests for path completions (join)
      > Fix quote completions for os.path.join path completions
      > Fix first param argument of os.path.join file completions
      > Fix arglist/trailer issues
      > in os.path.join completions, directories should not end in a slash
      > Make some file path completions in os.path.join work
      > Fix os.path.join static value gathering
      > os.path.sep should always have a clear value
      > Fix string name completion for stuff like dirname and abspath
      > Fix bytes issue with file path adding
      > Python 2 compatibility
      > Make __file__ return the correct value
      > Fix string additions when used in certain ways
      > Make string additions work for file path completion
      > Fix interpeter project path
      > Fix the REPL completer for file path completions
      > Fix a few more file name completion cases
      > A first iteration for file path completions
      > Fix a test failure
      > Add Definition.execute, fixes #1076
      > Add tests to show that #516 is not working, yet
      > List possible Definition.type in its docstring, fixes #1069.
      > Start writing the Changelog for 0.15.0
      > 3.8-dev should not be allowed to fail
      > Skip more Python 2 tests
      > Skipping of tests was done the wrong way again
      > Skip the right tests
      > Parameter.kind is not avaialble in Python 3.5
      > Fix Python 2 test issues
      > Add a few docstrings to make some things clearer
      > Add ParamDefinition.kind, fixes #1361
      > Make it possible to format a param to a string, fixes #1074
      > Add another test for signature annotations
      > Add Signature.to_string() with proper tests, fixes #779, fixes #780
      > Test infer_default
      > Use a helper to create definitions
      > Add a execute_annotation option to infer_annotation
      > Test infer_annotation
      > Make it possible for users to infer annotations/defaults
      > A first iteration of adding signatures to the API, fixes #1139
      > Fix a caching issue
      > Forgot the right resolve_stars parameters in one place
      > Cache getting resolved param names
      > Turn around resolve_stars, it shouldn't by default be resolved
      > Remove a class that is not needed anymore
      > Revert "Use __str__ instead of to_string"
      > Fix the last remaining issues with function signature
      > overloaded_functions should be private
      > Use __str__ instead of to_string
      > Better repr for CallSignature
      > Fix some minor signature issues
      > Remove the unused function signature_matches
      > Fix signatures for __init__ calls when used with supers, fixes #1163
      > Fix some issues for args resolving in method calls
      > Remove a bit of code that i sprobably unused
      > Move get_signatures from Function to FunctionMixin
      > Merge the signature changes
      > Remove an import
      > Small refactoring
      > Skipped Python 2 Interpreter tests the wrong way
      > Remove a paragraph in docs that was arguing that stubs and generics (and other things) were not properly supported, fixes #1012
      > Fix partial signatures for MixedObject
      > Fix partial signatures, fixes #1371
      > Make sure with a test that the staticmethod signature is also correct
      > Fix classmethod signature, fixes #498
      > Deal with annotation on *args and **kwargs correctly, fixes #980
      > Use LazyContextWrapper more
      > Very small refactoring
      > Fix for failing assertion on native modules Issue #1354 (#1370)
      > Skip numpydoc tests for Python 2
      > Remove code that didn't mean anything
      > Fix docstrings for wrapped functions, fixes #906
      > Fix an isue about dict ordering in Python before 3.6.
      > Make it clearer when get_param is used.
      > A small dataclass refactoring
      > Evaluate annotations for dataclasses when infer is called on param
      > Get inheritance of dataclass right
      > A first working iteration of dataclass signatures, fixes #1213
      > Remove an unused function
      > Dataclass progress
      > Add enum changes to changelog
      > Fix a recursion error about getting metaclasses
      > One test about recursion issues only applied to Python 2
      > Use class filters in instances differently so metaclass plugins work, fixes #1090
      > First step in working with metaclasses in plugins, see #1090.
      > Refactor the plugin registry
      > Remove classes from plugins and use decorators instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants