Shougo / ddu-ui-ff

Fuzzy finder UI for ddu.vim
MIT License
55 stars 26 forks source link

`nofile` previewer contents are not saved #82

Closed tennashi closed 1 year ago

tennashi commented 1 year ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

Once an item has been previewed, previewing another item and then previewing it again will empty the buffer.

The following code may be the reason why the contents of the buffer are not saved. https://github.com/Shougo/ddu-ui-ff/blob/36a0c44165ef081740b8721c7a8a4fe3b2a93e90/denops/%40ddu-ui-ff/preview.ts#L231-L245

Expected

preview contents are displayed.

Environment Information

Provide a minimal init.vim/vimrc without plugin managers (Required!)

" Your minimal init.vim/vimrc
set runtimepath+=~/path/to/ddu.vim/
set runtimepath+=~/path/to/ddu-ui-ff/
set runtimepath+=~/path/to/test/

call ddu#custom#patch_global({
\ 'uiParams': {
\   'ff': {
\     'autoAction': {'name': 'preview'},
\   },
\ },
\})

type Params = Record<never, never>;

export class Source extends BaseSource { kind = "test";

gather(_args: GatherArguments): ReadableStream<Item[]> { return new ReadableStream({ start(controler) { controler.enqueue([ { word: "test-1" }, { word: "test-2" }, ]); controler.close(); }, }); }

params(): Params { return {}; } }


* `~/path/to/test_kind/denops/@ddu-kinds/test.ts`
```ts
import {
  ActionArguments,
  ActionFlags,
  BaseKind,
  Previewer,
} from "https://deno.land/x/ddu_vim@v2.4.0/types.ts";
import { GetPreviewerArguments } from "https://deno.land/x/ddu_vim@v2.4.0/base/kind.ts";

type Params = Record<never, never>;

export class Kind extends BaseKind<Params> {
  actions: Record<
    string,
    (args: ActionArguments<Params>) => Promise<ActionFlags>
  > = {};

  getPreviewer(_args: GetPreviewerArguments): Promise<Previewer | undefined> {
    return Promise.resolve({
      kind: "nofile",
      contents: ["hoge"],
    });
  }

  params(): Params {
    return {};
  }
}

How to reproduce the problem from neovim/Vim startup (Required!)

  1. :call ddu#start({'ui': 'ff', 'sources': [{'name': 'test'}]}) (preview test-1)
  2. j (preview test-2)
  3. k (preview test-1)

Screenshot (if possible)

Upload the log messages by :redir and :message (if errored)

Shougo commented 1 year ago

Please test the latest version. It seems fixed.

tennashi commented 1 year ago

Looks like the problem has not been fixed yet. The reproduction procedure and the minimum code still confirm the occurrence of the problem. @Shougo

Shougo commented 1 year ago

Fixed.