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

Fix text objects to be line-wise rather than character-wise operator #1037

Merged
merged 4 commits into from Sep 4, 2020

Conversation

@lieryan
Copy link
Contributor

@lieryan lieryan commented Jun 29, 2019

The text objects command like daC and diM previously worked using character-wise selection. This is rarely what the user want, as it means that pasting with (p) does not work if your cursor is not on column 0 and paste with reindent (]p) does not work at all.

This PR changes these text objects to be line-wise, which aligns it with other similar builtin motion commands like dap/dip (delete a/inner paragraph).

All tests seems to pass, though I'm not quite sure how to add a new test for this.

@lieryan lieryan force-pushed the lieryan:lieryan-pymode-selection branch from b760bef to a59310e Oct 17, 2019
@diraol
Copy link
Contributor

@diraol diraol commented Apr 21, 2020

Hi @lieryan !

Sorry for this massive late feedback. I've had tough personal issues last year that made me stay away from this project (even from my work). I still don't have too much time to dedicate to the project, but I'll try to get back to it.

Can you please provide a minimal working example for me to test the behavior before and after your change?

Like, a simple .py file and the sequence of commands to perform to see how your PR is changing what is going on?

Thank you very much for your contribution! Oh, and please, also add yourself to the Authors file!

@lieryan
Copy link
Contributor Author

@lieryan lieryan commented Apr 25, 2020

Hi, thanks for coming back. I've added actual test for the textobject.vim to test the behaviour of what this PR implements.

So a test example would be:

def func1():
    a = 1
def func2():
    b = 2

If you used the daM on func2() and the you moved your cursor to, say the ( character in func1() and then you pasted with P, previously because the text objects are character text object, the buffer content would look like:

def func1def func2():
    b = 2():
    a = 1

After the change, the buffer content will now look like (note the position of func1() and func2() are swapped from original file):

def func2():
    b = 2
def func1():
    a = 1

This works similar to other line-wise text objects like dap (delete a paragraph).

@lieryan lieryan force-pushed the lieryan:lieryan-pymode-selection branch 2 times, most recently from b194e79 to 242c2de Apr 25, 2020
lieryan added 4 commits Jun 29, 2019
For some reason, vim will still add packages even when -u is specified.
This flag tells vim to avoid loading those packages. This should improve
test isolation.
@lieryan lieryan force-pushed the lieryan:lieryan-pymode-selection branch from 242c2de to ff89053 Apr 25, 2020
@diraol diraol merged commit 295e84d into python-mode:develop Sep 4, 2020
@diraol
Copy link
Contributor

@diraol diraol commented Sep 4, 2020

Thank you very much for your contribution! :) (better late than never!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.