From 10f92836e6fce10f4bedbf2278b6ffc71eff3ab8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 12 Jun 2013 17:16:10 -0700 Subject: [PATCH] Rename path variables to prevent collisions --- spec/app/project-spec.coffee | 28 +++++++++++++--------------- src/app/project.coffee | 10 +++++----- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/spec/app/project-spec.coffee b/spec/app/project-spec.coffee index 3b73d9b86..910c8087c 100644 --- a/spec/app/project-spec.coffee +++ b/spec/app/project-spec.coffee @@ -40,8 +40,8 @@ describe "Project", -> newEditSessionHandler = jasmine.createSpy('newEditSessionHandler') project.on 'edit-session-created', newEditSessionHandler - fooOpener = (path, options) -> { foo: path, options } if path?.match(/\.foo/) - barOpener = (path) -> { bar: path } if path?.match(/^bar:\/\//) + fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/) + barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//) Project.registerOpener(fooOpener) Project.registerOpener(barOpener) @@ -212,8 +212,7 @@ describe "Project", -> it "calls the callback with all regex matches in all files in the project", -> matches = [] waitsForPromise -> - project.scan /(a)+/, ({path, match, range}) -> - matches.push({path, match, range}) + project.scan /(a)+/, (match) -> matches.push(match) runs -> expect(matches[0]).toEqual @@ -229,8 +228,7 @@ describe "Project", -> it "works with with escaped literals (like $ and ^)", -> matches = [] waitsForPromise -> - project.scan /\$\w+/, ({path, match, range}) -> - matches.push({path, match, range}) + project.scan /\$\w+/, (match) -> matches.push(match) runs -> expect(matches.length).toBe 1 @@ -295,9 +293,9 @@ describe "Project", -> paths = [] matches = [] waitsForPromise -> - project.scan /match/, ({path, match, range}) -> - paths.push(path) - matches.push(match) + project.scan /match/, (result) -> + paths.push(result.path) + matches.push(result.match) runs -> expect(paths.length).toBe 0 @@ -311,9 +309,9 @@ describe "Project", -> paths = [] matches = [] waitsForPromise -> - project.scan /match this/, ({path, match, range}) -> - paths.push(path) - matches.push(match) + project.scan /match this/, (result) -> + paths.push(result.path) + matches.push(result.match) runs -> expect(paths.length).toBe 1 @@ -328,9 +326,9 @@ describe "Project", -> paths = [] matches = [] waitsForPromise -> - project.scan /match/, ({path, match, range}) -> - paths.push(path) - matches.push(match) + project.scan /match/, (result) -> + paths.push(result.path) + matches.push(result.match) runs -> expect(paths.length).toBe 0 diff --git a/src/app/project.coffee b/src/app/project.coffee index 0c6b3a340..7aebd0b5a 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -223,20 +223,20 @@ class Project scan: (regex, iterator) -> bufferedData = "" state = 'readingPath' - path = null + filePath = null readPath = (line) -> if /^[0-9,; ]+:/.test(line) state = 'readingLines' else if /^:/.test line - path = line.substr(1) + filePath = line.substr(1) else - path += ('\n' + line) + filePath += ('\n' + line) readLine = (line) -> if line.length == 0 state = 'readingPath' - path = null + filePath = null else colonIndex = line.indexOf(':') matchInfo = line.substring(0, colonIndex) @@ -251,7 +251,7 @@ class Project for [column, length] in matchPositions range = new Range([row, column], [row, column + length]) match = lineText.substr(column, length) - iterator({path, range, match}) + iterator({path: filePath, range, match}) deferred = $.Deferred() errors = []