LumaKernel / ddc-source-file

Powerful and performant file name completion for ddc.vim.
MIT License
48 stars 6 forks source link

ddc_file#internal#info() is broken #9

Closed Shougo closed 3 years ago

Shougo commented 3 years ago
diff --git a/autoload/ddc_file/internal.vim b/autoload/ddc_file/internal.vim
index 8b50071..c8b900c 100644
--- a/autoload/ddc_file/internal.vim
+++ b/autoload/ddc_file/internal.vim
@@ -22,9 +22,8 @@ endfunction
 "   string,
 "   string,
 " ]}
-function! ddc_file#internal#info(is_posix) abort
-  let input_line = getline('.')[: col('.') - 2]
-  let input_file_full = s:line_to_file_full(input_line, a:is_posix)
+function! ddc_file#internal#info(is_posix, input_line) abort
+  let input_file_full = s:line_to_file_full(a:input_line, a:is_posix)
   let input_file_base_prefix = s:full_to_base_prefix(input_file_full, a:is_posix)
   let buf_path = expand('%:p')
   return [
diff --git a/denops/@ddc-file/internal_autoload_fn.ts b/denops/@ddc-file/internal_autoload_fn.ts
index beabbac..a2edefb 100644
--- a/denops/@ddc-file/internal_autoload_fn.ts
+++ b/denops/@ddc-file/internal_autoload_fn.ts
@@ -12,6 +12,7 @@ const createCaller = (name: string): any => {
 export type Info = (
   denops: Denops,
   isPosix: boolean,
+  inputLine: string,
 ) => Promise<[
   string,
   string,
diff --git a/denops/@ddc-sources/file.ts b/denops/@ddc-sources/file.ts
index 00173b6..f87518d 100644
--- a/denops/@ddc-sources/file.ts
+++ b/denops/@ddc-sources/file.ts
@@ -80,6 +80,7 @@ export class Source extends BaseSource<Params> {
     const [inputFileFull, inputFileBasePrefix, bufPath] = await internal.info(
       args.denops,
       mode === "posix",
+      args.context.input,
     );

     // e.g. '/home/ubuntu/config' for inputFileFull = '~/config'

Please don't use getline() in source. It does not work in command line.

LumaKernel commented 3 years ago

Is inputLine equal to "e foo/" for :e foo/<cursor>/bar?

Shougo commented 3 years ago

Yes.

LumaKernel commented 3 years ago

Thank you!