Skip to content

Commit 2739d27

Browse files
authored
Merge pull request #165 from atom-community/this-bind
fix: determineProjectPath was called with the wrong `this`
2 parents 151a069 + e58c3a4 commit 2739d27

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/auto-languageclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export default class AutoLanguageClient {
315315
(filepath) => this.filterChangeWatchedFiles(filepath),
316316
this.reportBusyWhile,
317317
this.getServerName(),
318-
this.determineProjectPath,
318+
(textEditor: TextEditor) => this.determineProjectPath(textEditor),
319319
this.shutdownGracefully
320320
)
321321
this._serverManager.startListening()

test/auto-languageclient.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ describe("AutoLanguageClient", () => {
4747
// "returns null when a single file is open"
4848

4949
let textEditor = (await atom.workspace.open(__filename)) as TextEditor
50-
/* eslint-disable-next-line dot-notation */
50+
/* eslint-disable dot-notation */
5151
expect(client["determineProjectPath"](textEditor)).toBeNull()
52+
expect(serverManager["_determineProjectPath"](textEditor)).toBeNull()
53+
/* eslint-enable dot-notation */
5254
textEditor.destroy()
5355

5456
// "returns the project path when a file of that project is open"
@@ -59,8 +61,10 @@ describe("AutoLanguageClient", () => {
5961
await serverManager.startServer(projectPath)
6062

6163
textEditor = (await atom.workspace.open(__filename)) as TextEditor
62-
/* eslint-disable-next-line dot-notation */
64+
/* eslint-disable dot-notation */
6365
expect(client["determineProjectPath"](textEditor)).toBe(normalizePath(projectPath))
66+
expect(serverManager["_determineProjectPath"](textEditor)).toBe(normalizePath(projectPath))
67+
/* eslint-enable dot-notation */
6468
textEditor.destroy()
6569

6670
// "returns the project path when an external file is open and it is not in additional paths"
@@ -73,8 +77,10 @@ describe("AutoLanguageClient", () => {
7377
await serverManager.startServer(projectPath)
7478

7579
textEditor = (await atom.workspace.open(externalFile)) as TextEditor
76-
/* eslint-disable-next-line dot-notation */
80+
/* eslint-disable dot-notation */
7781
expect(client["determineProjectPath"](textEditor)).toBeNull()
82+
expect(serverManager["_determineProjectPath"](textEditor)).toBeNull()
83+
/* eslint-enable dot-notation */
7884
textEditor.destroy()
7985

8086
// "returns the project path when an external file is open and it is in additional paths"
@@ -87,8 +93,10 @@ describe("AutoLanguageClient", () => {
8793
expect(server.additionalPaths?.has(externalDir)).toBeTrue()
8894

8995
textEditor = (await atom.workspace.open(externalFile)) as TextEditor
90-
/* eslint-disable-next-line dot-notation */
96+
/* eslint-disable dot-notation */
9197
expect(client["determineProjectPath"](textEditor)).toBe(normalizePath(projectPath))
98+
expect(serverManager["_determineProjectPath"](textEditor)).toBe(normalizePath(projectPath))
99+
/* eslint-enable dot-notation */
92100
textEditor.destroy()
93101
})
94102
})

0 commit comments

Comments
 (0)