Suggestion: allow case-insensitive command completion in the shell

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Minor - P4
    • 2.1.0
    • Affects Version/s: None
    • Component/s: Shell
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      JavaScript is a case-sensitive language, which is generally a fine feature, but it makes typing in legal JavaScript a little harder than it might be. The problem is when you created a property and don't remember exactly how you used camelCase in it. For example:

      MongoDB shell version: 2.1.0-pre-
      > user=

      {firstName:"Jim",lastName:"Smith",ZipCode:12345} { "firstName" : "Jim", "lastName" : "Smith", "ZipCode" : 12345 }

      > user.zip // hit tab – command completion doesn't work because you spelled ZipCode with an initial cap
      > user.ZipCode = 98765 // if command completion was case-insensitive, it could correct your typing in its completion
      98765
      >

      The code that provides the command completion is in JavaScript and is doing a simple string comparison of possibilities with what we are trying to match. See shell/utils.js and matching code in shell/mongo_vstudio.cpp .

      if (p.substr(0, lastPrefix.length) != lastPrefix) continue; // skip items that don't match (my comment)

      It could easily do a case-insensitive comparison instead.

      if (p.substr(0, lastPrefix.length).toLowerCase() != lastPrefixLowercase) continue; // set up lastPrefixLowercase before loop

      The code would always return the case-correct completion, so this is just a convenience in typing, making the tab completion feature a tiny bit more useful. The cases where users would be annoyed by seeing case-insensitive matches seem likely to be fewer than the cases where this would be helpful.

            Assignee:
            Tad Marshall
            Reporter:
            Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: