Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Unified asynchronous event to avoid over-render #7

Closed
weirongxu opened this issue Sep 19, 2019 · 0 comments
Closed

[Feature]: Unified asynchronous event to avoid over-render #7

weirongxu opened this issue Sep 19, 2019 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@weirongxu
Copy link
Owner

weirongxu commented Sep 19, 2019

if (!workspace.env.isVim) {
events.on(
['BufCreate', 'BufHidden', 'BufUnload', 'BufWritePost', 'InsertLeave'],
debounce(500, async () => {
await this.reload(null);
}),
);
} else if (workspace.env.isVim) {
onBufEnter(500, async (bufnr) => {
if (bufnr === this.explorer.bufnr) {
await this.reload(null, { render: false });
}
});
}

if (!workspace.env.isVim) {
if (autoReveal) {
onBufEnter(200, async (bufnr) => {
if (bufnr !== this.explorer.bufnr) {
const bufinfo = await nvim.call('getbufinfo', [bufnr]);
if (bufinfo[0] && bufinfo[0].name) {
const item = await this.revealItemByPath(bufinfo[0].name as string);
if (item !== null) {
await execNotifyBlock(async () => {
await this.render({ storeCursor: false, notify: true });
await this.gotoItem(item, { notify: true });
nvim.command('redraw', true);
});
}
}
}
});
}
events.on(
'BufWritePost',
debounce(1000, async (bufnr) => {
const bufinfo = await nvim.call('getbufinfo', [bufnr]);
if (bufinfo[0] && bufinfo[0].name) {
await gitManager.reload(pathLib.dirname(bufinfo[0].name as string), this.showHiddenFiles);
await this.render();
}
}),
);
events.on(
['InsertLeave', 'TextChanged'],
debounce(1000, async () => {
let needRender = false;
if (fileColumnManager.columns.includes('diagnosticError')) {
if (diagnosticManager.errorReload()) {
needRender = true;
}
}
if (fileColumnManager.columns.includes('diagnosticWarning')) {
if (diagnosticManager.warningReload()) {
needRender = true;
}
}
if (needRender) {
await this.render();
}
}),
);
} else {
onBufEnter(200, async (bufnr) => {
if (bufnr === this.explorer.bufnr) {
await this.reload(null);
}
});
}
}, 30);

@weirongxu weirongxu added the enhancement New feature or request label Sep 19, 2019
@weirongxu weirongxu added this to the v1.0.0 milestone Sep 19, 2019
@weirongxu weirongxu changed the title Unified asynchronous event to avoid over-render [Feature]: Unified asynchronous event to avoid over-render Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant