1

Re: ViEmu 2.0 VB Paste Bug

Hi there,

Let me start by saying ViEmu 2.0 is the best version yet!  Hlsearch is a fantastic feature and the new visual mode feels so much more solid than previous versions.

I have encountered a problem though, and I'm not sure whether it is Visual Studio, or ViEmu, however I *have* confirmed that it doesn't happen with ViEmu 1.4.

I have the following code:

   If 1 = 1 Then _
       Debug.Writeline( _
          "Hello World" _
       )

I enter visual mode with Y, highlight the four lines, use D to delete them into the paste buffer, move away from that position, then use p to paste them, I get the following:

   If 1 = 1 Then
       Debug.Writeline( _
          "Hello World" _
       )

Notice the first underscore has disappeared. This seems to happen quite consistently, and didn't happen with previous versions.

Thanks,

Johan.

2

Re: ViEmu 2.0 VB Paste Bug

Johan,

I am not very well versed in Visual Basic, but I think I know what might be happening.

ViEmu 2.0 uses the language service's code to enter new line breaks. This provides VS-standard autoindent features, which ViEmu 1.x didn't in many cases. But VB.NET's language service is pretty special (and has given me many, many headaches), and it takes a lot of freedom in reformatting the current line when you ask it to just enter a line break.

Since VB, by default, would not insert an underscore after the "then", it just decides to remove it. The other ones are preserved because they are in the middle of a function call.

If this is the cause, the solution is pretty difficult - since ViEmu can not easily tell when you'd be interested in language-service autoindent versus raw line breaks. A user setting to configure this wouldn't make much sense, either, given you really want it most of the time (when typing, when using o/O, when repeating input with '.', etc).

Let me know if you think it's something else. Of course, if it's a bug or if there is a simple fix, I'll be very happy to prepare a new build.

3

Re: ViEmu 2.0 VB Paste Bug

Yeh, that seems to be the case, as I've found a bunch of different cases where copying and pasting using the new ViEmu visual mode causes the language services to totally screw up code below, for instance reindenting lines or doing really dumb things like adding parentheses to every member of near by enums.

If I use the Visual Studio selection for visual mode then the problems go away, which is a real shame as the new ViEmu visual mode feels so much more solid and performs more like Vim does.

I don't claim to know anything about the editor parsing or language services, so I couldn't say whether a fix would be easy.

To be honest I hate Visual Basic - just have to convince the project manager to convert all 400 000 lines in the project to C# smile

4

Re: ViEmu 2.0 VB Paste Bug

Johan, 400k lines seems like an argument with some weight. If you can tell me some detailed steps to reproduce it, I might be able to find a workaround for VB.NET.

5

Re: ViEmu 2.0 VB Paste Bug

Alright.

My initial example in this thread showed the underscores disappearing. It happens also when large amounts of code is yanked/deleted then pasted, but doesn't remove all the underscores - most often it only removes the *first* underscore found in the selection.

I have one other example for you which I have confirmed does not happen in ViEmu 1.4.

Given the code:
    Public Sub DoSomething()

    End Sub

    Public Enum Numbers
        One
        Two
        Three
        Four
        Five
        Six
    End Enum

1. Position the cursor on the first line "Public Sub ..."
2. V to enter visual line selection
3. Down twice to select the three lines of the function.
4. D to delete into the paste buffer.
5. P to paste before the cursor.

The result is the following:
    Public Sub DoSomething()

    End Sub

    Public Enum Numbers
        One()
        Two()
        Three()
        Four()
        Five()
        Six()
    End Enum

Extra parantheses have been added to every member of the enumeration, causing compiler errors. This unfortunately happens *with* or *without* the "Use Visual Studio selection for Visual Mode" option selected, indicating a deeper seated problem with the interaction between ViEmu and the editor's parser and not to do with the new visual mode.

Hope this helps.

Johan.

6

Re: ViEmu 2.0 VB Paste Bug

Johan, thanks for the detailed repro steps. I'll have a look at this in the next few days and get back to you, hopefully with a new build. It's indeed pretty bad!

7

Re: ViEmu 2.0 VB Paste Bug

Awesome, thanks.