Skip to content

Commit

Permalink
Merge pull request #244 from vim-denops/fix-verbose
Browse files Browse the repository at this point in the history
🐛 Fix behavior on `verbose` environment
  • Loading branch information
lambdalisue committed May 14, 2024
2 parents 83978e8 + eb296e0 commit 52b4d51
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
- name: Update dependencies and commit changes
run: deno task -q upgrade:commit --summary ../title.txt --report ../body.md
run: deno task -q update:commit --summary ../title.txt --report ../body.md
- name: Check result
id: result
uses: andstor/file-existence-action@v2
Expand Down
2 changes: 1 addition & 1 deletion autocmd/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function list(
}
}
const expr = terms.join(" ");
return await denops.call("execute", expr);
return await denops.call("execute", `0verbose ${expr}`);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions autocmd/common_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,27 @@ test({
});
});

const verboseSaved = await denops.eval("&verbose");
await t.step({
name: "list() lists autocmds",
fn: async () => {
await define(denops, "User", "DenopsTestList", "echo '1'");
await define(denops, "User", "DenopsTestList", "echo '2'");
await define(denops, "User", "DenopsTestList", "echo '3'");
await denops.cmd(`set verbose=0`);
assertEquals(
await list(denops, "User", "DenopsTestList"),
[
"",
"--- Autocommands ---",
"User",
" DenopsTestList",
" echo '1'",
" echo '2'",
" echo '3'",
].join("\n"),
);
await denops.cmd(`set verbose=1`);
assertEquals(
await list(denops, "User", "DenopsTestList"),
[
Expand All @@ -183,6 +198,7 @@ test({
);
},
});
await denops.cmd(`set verbose=${verboseSaved}`);

await t.step({
name: "emit() emits an autocmd",
Expand Down
13 changes: 4 additions & 9 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
{
"lock": false,
"exclude": [
"docs/**",
".deps/**",
".coverage/**"
],
"exclude": ["docs/**", ".coverage/**"],
"imports": {
"https://deno.land/x/denops_std@$MODULE_VERSION/": "./"
},
"tasks": {
"check": "deno check ./**/*.ts",
"test": "deno test -A --doc --parallel --shuffle",
"test:coverage": "deno task test --coverage=.coverage",
"check": "deno check ./**/*.ts",
"coverage": "deno coverage .coverage",
"upgrade": "deno run -q -A https://deno.land/x/molt@0.14.0/cli.ts ./**/*.ts",
"upgrade:commit": "deno task -q upgrade --commit --prefix :package: --pre-commit=fmt",
"update": "deno run --allow-env --allow-read --allow-write=. --allow-run=git,deno --allow-net=deno.land,jsr.io,registry.npmjs.org jsr:@molt/cli ./*.ts",
"update:commit": "deno task -q update --commit --pre-commit=fmt,lint",
"gen:function": "deno run -A ./.scripts/gen-function/gen-function.ts",
"gen:option": "deno run -A ./.scripts/gen-option/gen-option.ts",
"gen": "deno task gen:function && deno task gen:option && deno fmt"
Expand Down
2 changes: 1 addition & 1 deletion helper/expr_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

import type { Context, Denops, Dispatcher, Meta } from "../mod.ts";
import is from "https://deno.land/x/unknownutil@v3.16.3/is.ts";
import { is } from "https://deno.land/x/unknownutil@v3.16.3/mod.ts";
import { execute } from "./execute.ts";
import { ulid } from "https://deno.land/std@0.217.0/ulid/mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion helper/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { batch } from "../batch/mod.ts";
import { register } from "../lambda/mod.ts";
import { feedkeys } from "../function/mod.ts";
import is from "https://deno.land/x/unknownutil@v3.16.3/is.ts";
import { is } from "https://deno.land/x/unknownutil@v3.16.3/mod.ts";

export type Keys = {
keys: string | ExprString;
Expand Down
5 changes: 4 additions & 1 deletion mapping/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ export async function list(
options: ListOptions = {},
): Promise<Mapping[]> {
const mode = options.mode ?? "";
const result = await fn.execute(denops, `${mode}map ${lhs}`) as string;
const result = await fn.execute(
denops,
`0verbose ${mode}map ${lhs}`,
) as string;
return result.split(/\r?\n/).flatMap((v) => {
try {
return [parse(v)];
Expand Down
25 changes: 23 additions & 2 deletions mapping/mod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ test({
},
});

const verboseSaved = await denops.eval("&verbose");
for (const mode of modes) {
await t.step({
name: `list() lists mappings starts from {lhs} (${mode}map)`,
Expand All @@ -579,14 +580,33 @@ test({
mode,
},
);
const result = await mapping.list(
await denops.cmd(`set verbose=0`);
const result1 = await mapping.list(
denops,
`<Plug>(test-denops-std-list-${mode}map)`,
{
mode,
},
);
assertEquals(result, [
assertEquals(result1, [
{
mode,
lhs: `<Plug>(test-denops-std-list-${mode}map)`,
rhs: "Hello",
noremap: false,
script: false,
buffer: false,
},
]);
await denops.cmd(`set verbose=1`);
const result2 = await mapping.list(
denops,
`<Plug>(test-denops-std-list-${mode}map)`,
{
mode,
},
);
assertEquals(result2, [
{
mode,
lhs: `<Plug>(test-denops-std-list-${mode}map)`,
Expand All @@ -599,5 +619,6 @@ test({
},
});
}
await denops.cmd(`set verbose=${verboseSaved}`);
},
});

0 comments on commit 52b4d51

Please sign in to comment.