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

👍 Add denops#interrupt() #348

Merged
merged 2 commits into from
Jun 4, 2024
Merged

👍 Add denops#interrupt() #348

merged 2 commits into from
Jun 4, 2024

Conversation

lambdalisue
Copy link
Member

@lambdalisue lambdalisue commented May 14, 2024

Close #307

For manual test

Create a denops plugin called interrupt-test with the following code

import type { Denops as DenopsOrigin } from "https://deno.land/x/[email protected]/mod.ts";
import { abortable, delay } from "https://deno.land/[email protected]/async/mod.ts";

export function main(denops: Denops): void {
  denops.dispatcher = {
    start: async () => {
      const signal = denops.interrupted;
      try {
        for (let i = 0; i < 100; i++) {
          signal.throwIfAborted();
          await abortable(denops.cmd(`echo 'Hello ${i}'`), signal);
          await delay(100, { signal });
        }
      } catch (e) {
        if (e instanceof DOMException && e.name === "AbortError") {
          await denops.cmd("echo 'Interrupted'");
          return;
        }
        throw e;
      }
    },
  };
}

// Assume that Denops v7.0 add `interrupted` attribute to Denops
type Denops = DenopsOrigin & {
  interrupted: AbortSignal;
};

Then add <C-c> mapping like

nnoremap <silent> <C-c> <Cmd>call denops#interrupt()<CR>

Then

  1. Invoke `call denops#notify('interrupt-test', 'start', [])
  2. Interrupt with <C-c>
  3. If Interrupted is echoed, success.
CleanShot.2024-06-01.at.16.37.53.mp4

@lambdalisue lambdalisue marked this pull request as draft May 14, 2024 18:15
Copy link

coderabbitai bot commented May 14, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.26%. Comparing base (060da2e) to head (957d17a).

Additional details and impacted files
@@            Coverage Diff             @@
##           v7-pre     #348      +/-   ##
==========================================
+ Coverage   91.13%   91.26%   +0.12%     
==========================================
  Files          17       17              
  Lines        1015     1030      +15     
  Branches      107      108       +1     
==========================================
+ Hits          925      940      +15     
  Misses         89       89              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lambdalisue lambdalisue modified the milestones: v7.0, v6.1 May 27, 2024
@lambdalisue lambdalisue changed the base branch from main to v7-pre June 1, 2024 06:48
@lambdalisue lambdalisue force-pushed the support-interrupt branch 2 times, most recently from 0d71608 to fa1c045 Compare June 1, 2024 07:05
@lambdalisue lambdalisue marked this pull request as ready for review June 1, 2024 07:06
lambdalisue added a commit to vim-denops/deno-denops-core that referenced this pull request Jun 1, 2024
@lambdalisue lambdalisue force-pushed the support-interrupt branch 4 times, most recently from 1292f6a to 0605cbc Compare June 1, 2024 07:22
@lambdalisue lambdalisue force-pushed the v7-pre branch 2 times, most recently from dfbd1cd to 060da2e Compare June 1, 2024 07:32
@lambdalisue lambdalisue merged commit deae6e0 into v7-pre Jun 4, 2024
9 checks passed
@lambdalisue lambdalisue deleted the support-interrupt branch June 4, 2024 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to interrupt background process running on Deno
1 participant