Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B910C11AC7 for ; Mon, 23 Jun 2014 08:54:45 +0000 (UTC) Received: (qmail 22002 invoked by uid 500); 23 Jun 2014 08:54:45 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 21942 invoked by uid 500); 23 Jun 2014 08:54:45 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 21929 invoked by uid 99); 23 Jun 2014 08:54:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2014 08:54:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C1E69886F51; Mon, 23 Jun 2014 08:54:44 +0000 (UTC) From: garrensmith To: dev@couchdb.apache.org Reply-To: dev@couchdb.apache.org References: In-Reply-To: Subject: [GitHub] couchdb pull request: 2160 string edit Content-Type: text/plain Message-Id: <20140623085444.C1E69886F51@tyr.zones.apache.org> Date: Mon, 23 Jun 2014 08:54:44 +0000 (UTC) Github user garrensmith commented on a diff in the pull request: https://github.com/apache/couchdb/pull/251#discussion_r14065694 --- Diff: src/fauxton/app/addons/documents/views.js --- @@ -765,6 +805,46 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, FauxtonAPI.navigate(this.database.url("index") + "?limit=100"); }, + determineStringEditMatch: function(event) { + var selStart = this.editor.editor.getSelectionRange().start.row; + var selEnd = this.editor.editor.getSelectionRange().end.row; + if (selStart >=0 && selEnd >= 0 && selStart == selEnd) { + var editLine = this.editor.editor.session.getLine(selStart); + var editMatch = editLine.match(/^([ \t]*)("[a-zA-Z0-9_]*": )?(".*",?[ \t]*)$/); + if (editMatch) { + return editMatch; + } else { + return null; + } + } else { + return null; + } + }, + + isStringEditingPossible: function (event) { + var editMatch = this.determineStringEditMatch(event); + if (editMatch) { + return true; + } + return false; + }, + + stringEditing: function(event) { + event.preventDefault(); + var editMatch = this.determineStringEditMatch(event); + if (editMatch) { + var indent = editMatch[1] || ""; + var hashKey = editMatch[2] || ""; + var editText = editMatch[3]; + var comma = ""; --- End diff -- This is just a personal taste and what we do in Fauxton. But could you make these variables only use one `var`. eg: var indent = editMatch[1] || "", hashKey = editMatch[2] || "", editText = editMatch[3], comma = ""; --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---