Skip to content

Loading…

Support for ip/ap "paragraph" text objects #172

Closed
dhleong opened this Issue · 11 comments

3 participants

@dhleong

I keep trying to use it and sometimes it works as expected, others... not so much. I noticed that it's not listed under supported text objects, though. Any plan to support?

Take a buffer like this, for example:

<resources>

    <style name="SomeTheme" >
        <item name="android:textColorPrimary">@color/primary_text_light</item>
        <item name="android:textColorSecondary">@color/secondary_text_light</item>

    </style>

</resources>

If I put my cursor on the first "style" on line 3 and type vip, vrapper selects from the first "resources" to the end of the line starting <item name="android:textColorSecondary while vim will select starting at the first <style and ending in the same place.

Or worse, typing vip at </style> selects the entire buffer in vrapper, while only that line should be selected.

This is in the latest unstable.

Thanks!

@dhleong

Also, not sure if it's related but the { and } motions also sometimes go more than a single paragraph as well. If unrelated, I can file a separate bug

@keforbes

Those two defects appear to be related, {, }, and p all use the same class, ParagraphMotion. It looks like someone didn't take the time to learn all the nuances of Vim's behavior before implementing that feature.

That class seems pretty self-contained and you seem to know how the paragraph motion is supposed to work, would you be willing to fix this yourself? I don't mind looking into it and attempting to fix it, but I probably won't get to it anytime this week and you just might be motivated enough to jump on it. Just let me know.
net.sourceforge.vrapper.vim.commands.motions.ParagraphMotion

@keforbes

I just tried the example you described and I'm not seeing any issue. Everything seems to work correctly. When I have the cursor on the first <style> tag and do vip, it correctly selects <style> and the two <item> lines. When I put the cursor on </style> it correctly selects only that line.

@keforbes

Are you on Windows by chance? I wonder if this is yet another time where I can blame it on Windows' \r\n line endings. I tested it out on linux and it works exactly as expected.

@dhleong

Nope, I'm on OSX. Every now and then it works okay, but almost 90% of the time it fails. I haven't had time to sit down with the vrapper source---I glanced at it earlier in the week but didn't have enough time to really grok it.

Here's another concrete example---I put it together in a separate Java file to make sure it wasn't some save issue---that repros 100% for me:

public class Test {

    private final int foo;
    private final int bar;

    public Test(int a, int b) {

        foo = a;
        bar = b;

    }
}

In vim, vip on the first "private" will select that line and the next, but vrapper will select that line to the end of the file. vip on the "public" of the constructor should select just that line, but vrapper selects the same thing as before (the first private final line to EOF).

@keforbes

I don't know what to say, that example also works perfectly for me. Have you verified that Eclipse isn't auto-indenting those empty lines? When those lines are completely empty (no whitespace), the feature works exactly as expected.

Are there any Mac OSX users that might be willing to test this out for me? I'm afraid I don't have access to a mac to try this out. I can't imagine this problem is OS related but I'm out of ideas.

@modosist

I also think this is a whitespace related problem. In current implementation for paragraph text objects, blank and "whitespace" lines are considered as different, but in Vim they are both considered as blank lines (but only for paragraph text objects). There are also some small defects for inner text commands (ip and friends), so I decided to reimplement it. I hope I will finish it soon (most of the code+tests is already written, I'm currently putting some finishing touches for files ending with EOL).

@keforbes

Ah, thank you @modosist. The Vim documentation defines a paragraph as "a paragraph begins after each empty line". Vrapper implemented that by not even allowing whitespace on a line so I thought we were doing the right thing. After trying it out in Vim, you're right, whitespace on an otherwise empty line is still treated as a paragraph boundary. All of the examples @dhleong posted had (what I assumed was correct) completely empty lines with no whitespace. In those examples, Vrapper works. However, if those lines actually had some tabs or spaces, Vrapper was deviating from Vim's behavior. Thank you for clarifying that and I look forward to your Pull Request!

@dhleong
@keforbes keforbes closed this in 7fcd62a
@keforbes

I've updated the unstable update site with a new build (0.29.20130317) which includes a fix for this defect (graciously provided by @modosist). Test it out and let us know if you have any problems with it. Thanks!

@dhleong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.