Skip to content

Commit

Permalink
firenvim.vim: fix g:started_by_firenvim not being set on windows
Browse files Browse the repository at this point in the history
Closes #315
  • Loading branch information
glacambre committed Jan 1, 2020
1 parent 6b05e4d commit 3791080
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/firenvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function! s:get_executable_content(data_dir, prolog) abort
return "@echo off\r\n" .
\ "cd \"" . a:data_dir . "\"\r\n" .
\ a:prolog . "\r\n" .
\ "\"" . s:get_progpath() . "\" --headless -c \"call firenvim#run()\"\r\n"
\ "\"" . s:get_progpath() . "\" --headless --cmd \"let g:started_by_firenvim = v:true\" -c \"call firenvim#run()\"\r\n"
endif
return "#!/bin/sh\n" .
\ 'cd ' . a:data_dir . "\n" .
Expand Down
30 changes: 30 additions & 0 deletions tests/_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,36 @@ export async function testModifiers(driver: any) {
await driver.wait(async () => ["\u0011<M-q><D-q>", "\u0001<M-a><D-a>"].includes(await input.getAttribute("value")));
}

export async function testGStartedByFirenvim(driver: any) {
await loadLocalPage(driver, "simple.html");
console.log("Locating textarea…");
const input = await driver.wait(Until.elementLocated(By.id("content-input")));
await driver.executeScript("arguments[0].scrollIntoView(true);", input);
console.log("Clicking on input…");
await driver.actions().click(input).perform();
console.log("Waiting for span to be created…");
const span = await driver.wait(Until.elementLocated(By.css("body > span:nth-child(2)")));
await driver.sleep(500);
console.log("Typing a<C-r>=g:started_by_firenvim<CR><Esc>:wq<CR>…");
await sendKeys(driver, ["a"])
await driver.actions()
.keyDown(webdriver.Key.CONTROL)
.keyDown("r")
.keyUp("r")
.keyUp(webdriver.Key.CONTROL)
.perform();
await sendKeys(driver, "=g:started_by_firenvim".split("")
.concat([webdriver.Key.ENTER])
.concat([webdriver.Key.ESCAPE])
.concat(":wq!".split(""))
.concat(webdriver.Key.ENTER));
await driver.sleep(500);
console.log("Waiting for span to be removed from page…");
await driver.wait(Until.stalenessOf(span));
console.log("Waiting for value update…");
await driver.wait(async () => (await input.getAttribute("value")) === "true");
}

export async function testCodemirror(driver: any) {
await loadLocalPage(driver, "codemirror.html");
console.log("Looking for codemirror div…");
Expand Down
2 changes: 2 additions & 0 deletions tests/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
testAce,
testCodemirror,
testDynamicTextareas,
testGStartedByFirenvim,
testGuifont,
testInputFocus,
testInputFocusedAfterLeave,
Expand Down Expand Up @@ -79,6 +80,7 @@ describe("Chrome", () => {
nonHeadlessTest()("Firenvim works on dynamically created elements", () => testDynamicTextareas(driver));
nonHeadlessTest()("Firenvim works on dynamically created nested elements", () => testNestedDynamicTextareas(driver));
nonHeadlessTest()("Firenvim works with large buffers", () => testLargeBuffers(driver));
nonHeadlessTest().only("g:started_by_firenvim exists", () => testGStartedByFirenvim(driver));
nonHeadlessTest()("Guifont works", () => testGuifont(driver));
nonHeadlessTest()("Input is focused after leaving frame", () => testInputFocusedAfterLeave(driver));
nonHeadlessTest()("InputFocus works", () => testInputFocus(driver));
Expand Down
2 changes: 2 additions & 0 deletions tests/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
testAce,
testCodemirror,
testDynamicTextareas,
testGStartedByFirenvim,
testGuifont,
testInputFocus,
testInputFocusedAfterLeave,
Expand Down Expand Up @@ -81,6 +82,7 @@ describe("Firefox", () => {
test("Firenvim works on dynamically created elements", () => testDynamicTextareas(driver));
test("Firenvim works on dynamically created nested elements", () => testNestedDynamicTextareas(driver));
test("Firenvim works with large buffers", () => testLargeBuffers(driver));
test("g:started_by_firenvim exists", () => testGStartedByFirenvim(driver));
test("Guifont works", () => testGuifont(driver));
test("Input is focused after leaving frame", () => testInputFocusedAfterLeave(driver));
test("InputFocus works", () => testInputFocus(driver));
Expand Down

0 comments on commit 3791080

Please sign in to comment.