Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-22484

Incorrect quoted text selection behavior

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • Qt Creator 4.9.0
    • FakeVim

    Description

      Consider the following C++ code.  | indicates my cursor.

      (The cursor is actually a box in normal mode, so it's on rather than between characters...)

      const std::string r = R"(
      {
          "Key1": "V|alue1",
          "Key2": "Value2"
      })"
      

      In regular Vim, typing ci" produces the following (and also switches to insert mode).  This is expected and desired. 

      const std::string r = R"(                                                                                                                             
      {                                                                           
          "Key1": "|",                                                             
          "Key2": "Value2"                                                        
      })";   

       

      QtCreator's FakeVim behavior is a little different.  It produces the following, which I think is incorrect:

       

      const std::string r = R"(
      {
          "Key1": "Value1"|"Key2": "Value2"
      })";
      

      It appears that the following method is to blame.

      bool FakeVimHandler::Private::selectQuotedStringTextObject(bool inner, const QString &quote)

       

      Some observations:

      • As far as I can tell, Vim's behavior with quotes + the a and i modifiers is line-based.  That is, doing things like ca' or ci" completely ignores quotes above and below the line in question.
      • In contrast, the behavior of FakeVim is influenced by quotes on preceding lines.  For instance, introducing an errant " above the const std::string... "fixes" the problem.  This behavior is clearly desirable for things like braces (ci{ would be useless if it was limited to individual lines) but I am not sure it is the right thing to do for quotes.
      • Even with obvious syntax errors, Vim attempts to do the right thing if you perform one of these commands while on top of a quote.  That is, it figures out whether the quote is an opening or closing quote and behaves accordingly.  It is possible to confuse it (for example, by putting everything in my example on one line), but its behavior when the cursor is inside the quotes is always correct. 
      • Vim and FakeVim have different behavior with ci"  and the following text.  
        "quoted1" unqu|oted "quoted2" 

       

       

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hjk hjk
            joel Joel Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes