-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix server crash when saving in nvim
- Loading branch information
Showing
7 changed files
with
228 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { assertEquals } from "../../deps.ts"; | ||
import { _changesFromFsEvents } from "./fs-mod.ts"; | ||
|
||
Deno.test("basic nvim modification works", () => { | ||
const modifications: Deno.FsEvent[] = [{ | ||
"kind": "create", | ||
"paths": ["content/4913"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/4913"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "access", | ||
"paths": ["content/4913"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "remove", | ||
"paths": ["content/4913"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/index.md~"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": [ | ||
"content/index.md", | ||
"content/index.md~", | ||
], | ||
"flag": undefined, | ||
}, { | ||
"kind": "create", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "access", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "remove", | ||
"paths": ["content/index.md~"], | ||
"flag": undefined, | ||
}]; | ||
|
||
const changes = _changesFromFsEvents()(modifications); | ||
assertEquals(changes, [{ type: "modify", inputPath: "content/index.md" }]); | ||
}); | ||
|
||
Deno.test("touching file results in single create", () => { | ||
const modifications: Deno.FsEvent[] = [{ | ||
"kind": "create", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "access", | ||
"paths": ["content/index.md"], | ||
"flag": undefined, | ||
}]; | ||
|
||
const changes = _changesFromFsEvents()(modifications); | ||
assertEquals(changes, [{ type: "create", inputPath: "content/index.md" }]); | ||
}); | ||
|
||
Deno.test("moving file results in delete and create", () => { | ||
const modifications: Deno.FsEvent[] = [{ | ||
"kind": "modify", | ||
"paths": ["content/test"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": ["content/test2"], | ||
"flag": undefined, | ||
}, { | ||
"kind": "modify", | ||
"paths": [ | ||
"content/test", | ||
"content/test2", | ||
], | ||
"flag": undefined, | ||
}]; | ||
|
||
const changes = _changesFromFsEvents()(modifications); | ||
assertEquals(changes, [ | ||
{ type: "delete", inputPath: "content/test" }, | ||
{ type: "create", inputPath: "content/test2" }, | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.