@@ -2,13 +2,11 @@ import type { Denops } from "https://deno.land/x/denops_core@v4.0.0/mod.ts";
2
2
import * as autocmd from "../autocmd/mod.ts" ;
3
3
import * as batch from "../batch/mod.ts" ;
4
4
import * as fn from "../function/mod.ts" ;
5
+ import * as op from "../option/mod.ts" ;
5
6
import { execute } from "../helper/mod.ts" ;
6
- import * as unknownutil from "https://deno.land/x/unknownutil@v2.1.0/mod.ts" ;
7
7
import {
8
- assertFileFormat ,
9
8
FileFormat ,
10
9
findFileFormat ,
11
- isFileFormat ,
12
10
maybeFileFormat ,
13
11
splitText ,
14
12
} from "./fileformat.ts" ;
@@ -268,21 +266,16 @@ export async function decode(
268
266
data : Uint8Array ,
269
267
options : DecodeOptions = { } ,
270
268
) : Promise < DecodeResult > {
271
- const [ fileformat , fileformatsStr , fileencodingsStr ] = await batch . gather (
269
+ const [ fileformat , fileformatsStr , fileencodingsStr ] = await batch . collect (
272
270
denops ,
273
- async ( denops ) => {
274
- await fn . getbufvar ( denops , bufnr , "&fileformat" ) ;
275
- await fn . getbufvar ( denops , bufnr , "&fileformats" ) ;
276
- await fn . getbufvar ( denops , bufnr , "&fileencodings" ) ;
277
- } ,
271
+ ( denops ) => [
272
+ op . fileformat . getBuffer ( denops , bufnr ) as Promise < FileFormat > ,
273
+ op . fileformats . get ( denops ) ,
274
+ op . fileencodings . get ( denops ) ,
275
+ ] ,
278
276
) ;
279
- assertFileFormat ( fileformat ) ;
280
- unknownutil . assertString ( fileformatsStr ) ;
281
- unknownutil . assertString ( fileencodingsStr ) ;
282
- const fileformats = fileformatsStr . split ( "," ) ;
277
+ const fileformats = fileformatsStr . split ( "," ) as FileFormat [ ] ;
283
278
const fileencodings = fileencodingsStr . split ( "," ) ;
284
- unknownutil . assertArray ( fileformats , isFileFormat ) ;
285
- unknownutil . assertArray ( fileencodings , unknownutil . isString ) ;
286
279
let enc : string ;
287
280
let text : string ;
288
281
if ( options . fileencoding ) {
@@ -478,17 +471,14 @@ export async function ensure<T>(
478
471
bufnr : number ,
479
472
executor : ( ) => T ,
480
473
) : Promise < T > {
481
- const [ bufnrCur , winidCur , winidNext ] = await batch . gather (
474
+ const [ bufnrCur , winidCur , winidNext ] = await batch . collect (
482
475
denops ,
483
- async ( denops ) => {
484
- await fn . bufnr ( denops ) ;
485
- await fn . win_getid ( denops ) ;
486
- await fn . bufwinid ( denops , bufnr ) ;
487
- } ,
476
+ ( denops ) => [
477
+ fn . bufnr ( denops ) ,
478
+ fn . win_getid ( denops ) ,
479
+ fn . bufwinid ( denops , bufnr ) ,
480
+ ] ,
488
481
) ;
489
- unknownutil . assertNumber ( bufnrCur ) ;
490
- unknownutil . assertNumber ( winidCur ) ;
491
- unknownutil . assertNumber ( winidNext ) ;
492
482
if ( winidCur === winidNext ) {
493
483
return executor ( ) ;
494
484
}
@@ -532,17 +522,14 @@ export async function modifiable<T>(
532
522
bufnr : number ,
533
523
executor : ( ) => T ,
534
524
) : Promise < T > {
535
- const [ modified , modifiable , foldmethod ] = await batch . gather (
525
+ const [ modified , modifiable , foldmethod ] = await batch . collect (
536
526
denops ,
537
- async ( denops ) => {
538
- await fn . getbufvar ( denops , bufnr , "&modified" ) ;
539
- await fn . getbufvar ( denops , bufnr , "&modifiable" ) ;
540
- await fn . getbufvar ( denops , bufnr , "&foldmethod" ) ;
541
- } ,
527
+ ( denops ) => [
528
+ op . modified . getBuffer ( denops , bufnr ) ,
529
+ op . modifiable . getBuffer ( denops , bufnr ) ,
530
+ op . foldmethod . getBuffer ( denops , bufnr ) ,
531
+ ] ,
542
532
) ;
543
- unknownutil . assertNumber ( modified ) ;
544
- unknownutil . assertNumber ( modifiable ) ;
545
- unknownutil . assertString ( foldmethod ) ;
546
533
await batch . batch ( denops , async ( denops ) => {
547
534
await fn . setbufvar ( denops , bufnr , "&modifiable" , 1 ) ;
548
535
await fn . setbufvar ( denops , bufnr , "&foldmethod" , "manual" ) ;
0 commit comments