[SERVER-4052] Suggestion: allow case-insensitive command completion in the shell Created: 10/Oct/11  Updated: 11/Jul/16  Resolved: 28/Nov/11

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 2.1.0

Type: Improvement Priority: Minor - P4
Reporter: Tad Marshall Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

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.



 Comments   
Comment by Tad Marshall [ 28/Nov/11 ]

Fixed by commit e5a54592f1ed5947b518ef1ca98ae91f68a2520a .

Comment by auto [ 28/Nov/11 ]

Author:

{u'login': u'', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-4052 – case-insensitive command completion in the shell

Provide command completions for partially typed commands without
requiring case-correctness in the partially typed command. The
completion (replacement) text is always case-correct, it's just
the to-be-replaced text that is now case-insensitive.
Branch: master
https://github.com/mongodb/mongo/commit/e5a54592f1ed5947b518ef1ca98ae91f68a2520a

Generated at Thu Feb 08 03:04:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.