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

💥 Minor breaking changes #300

Merged
merged 8 commits into from
Jan 2, 2024
Merged

💥 Minor breaking changes #300

merged 8 commits into from
Jan 2, 2024

Conversation

lambdalisue
Copy link
Member

@lambdalisue lambdalisue commented Dec 30, 2023

🐛 Fix fire timing of DenopsReady autocmd

Previously, the DenopsReady autocmd was fired when the channel was connected. However, it is not the right timing because the denops itself may not be ready yet. This commit fixes the timing of the autocmd so that denops is ready when the autocmd is fired.

If this change cause issue, developers should use denops#server#wait() or denops#server#wait_async() function to ensure that functions are called AFTER denops got ready. For example

call denops#server#wait_async({ -> denops#plugin#load('...', '...') })

💥 Read meta only once in initialization

This is a minor but a breaking change. This change affects the g:denops#debug variable. After this commit, the variable must be configured prior to the denops initialization.

💥 Synchronously call wait_async() callbacks

It seems timer_start() triks is no longer needed so we can call callbacks synchronously in both cases.

Let me know if this cause acutal issues (it might break lazy loading mech of denops that are not tested by myself.)

💥 Remove g:denops#trace option

The trace feature is not available when denops liberates from Worker and the feature obstructs the development of denops.

💥 Remove DenopsPluginRegister:* autocmd

We are planning to change internal registration mechanism and the autocmd is not suited for the new mechanism.

Quick search on GitHub shows that the autocmd is not used by anyones.

https://github.com/search?q=DenopsPluginRegister&type=code

💥 Remove {options} from register, reload, discover

We found that developers always use mode: "skip" and other options are not necessary. So we decided to remove {options} from functions and always use mode: "skip".

Quick search revelaed that no one uses reload and discover with {options} but some (e.g. dein.vim) uses register with {options}.

That's why we introduced a new load function that replaces register.

Developers who need to support previous denops should use load whenever possible like:

try
  call denops#plugin#load(
        \ "denops-hello",
        \ "/path/to/denops-hello/main.ts",
        \)
catch /^Vim\%((\a\+)\)\=:E117:/
  " Fallback to `register` for backward compatibility
  call denops#plugin#register(
        \ "denops-hello",
        \ "/path/to/denops-hello/main.ts",
        \ {"mode": "skip"},
        \)
endtry

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor

    • Streamlined plugin registration and reloading processes.
    • Enhanced internal message handling and dispatching mechanisms.
  • New Features

    • Implemented a more efficient signaling system within the server connection workflow.
  • Documentation

    • Updated the requirement for setting the debug configuration prior to initialization.
  • Bug Fixes

    • Addressed control flow issues in connection handling and service invocation.

Copy link

coderabbitai bot commented Dec 30, 2023

Walkthrough

The updates across various Vim script and TypeScript files in Denops reflect a shift in plugin handling and message dispatching. The changes streamline the flow by centralizing meta information and refining control mechanisms. This reorganization suggests a move towards more efficient and maintainable code, particularly in the way plugins register and reload, and how the system handles internal notifications and service sessions.

Changes

File Path Change Summary
autoload/denops.vim Removed denops#trace configuration definition.
autoload/denops/_internal/server/chan.vim Replaced doautocmd with s:rpcnotify in s:connect function.
autoload/denops/plugin.vim Refactored plugin registration logic, deprecated denops#plugin#register(), and introduced a new function for plugin loading.
denops/@denops-private/cli.ts Updated handleConn function, added isMeta import.
denops/@denops-private/host/invoker.ts Removed meta parameter from load and reload methods.
denops/@denops-private/host/{nvim.ts, vim.ts} Updated message handling and dispatching, added #invoker field.
denops/@denops-private/service.ts Included meta property in the Service class, updated register and reload methods.
doc/denops.txt Added initialization requirement for g:denops#debug variable, renamed denops#server#stop() to denops#server#close().
plugin/denops.vim Removed autocmd, added call to denops#server#wait_async in s:init().
denops/@denops-private/worker/script.ts Removed trace parameter from main function's signature, updated related logic.

Poem

🐇 In the den of code, where plugins abide,
🌟 Refactoring's done with a swift, smooth stride.
🧩 Pieces align in a dance of the bytes,
🎉 CodeRabbit cheers for the streamlined delights!

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 with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

codecov bot commented Dec 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b0812d3) 96.47% compared to head (be0bd9b) 96.47%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #300   +/-   ##
=======================================
  Coverage   96.47%   96.47%           
=======================================
  Files           3        3           
  Lines          85       85           
  Branches        6        6           
=======================================
  Hits           82       82           
  Misses          3        3           

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 405e919 and e91e0a1.
Files selected for processing (8)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/plugin.vim (2 hunks)
  • denops/@denops-private/cli.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (3 hunks)
  • denops/@denops-private/host/vim.ts (4 hunks)
  • denops/@denops-private/service.ts (5 hunks)
  • doc/denops.txt (1 hunks)
Additional comments: 22
denops/@denops-private/cli.ts (2)
  • 8-8: The addition of the isMeta import from ./util.ts is noted. Ensure that the isMeta function is used appropriately in the context of the changes.

  • 40-43: The introduction of the meta variable and the use of ensure with isMeta to validate the meta object is a good practice to ensure type safety. This change aligns with the PR's objective to read meta only once during initialization.

denops/@denops-private/host/invoker.ts (2)
  • 38-38: The removal of the meta parameter from the register method simplifies the method signature and aligns with the PR's objective to use a single meta instance.

  • 46-46: Similarly, the removal of the meta parameter from the reload method is consistent with the changes made to the register method and the PR's objectives.

denops/@denops-private/host/vim.ts (4)
  • 14-14: The addition of the isVoidMessage constant is a clear way to identify void messages, which seems to be a new concept introduced in this PR.

  • 34-45: The changes in the constructor to handle messages and dispatch them accordingly are significant. It's important to ensure that the #invoker is properly initialized before any messages are dispatched to avoid runtime errors.

  • 77-77: Assigning the invoker property in the register method is a straightforward change that supports the new message handling logic.

  • 93-102: The dispatch function's refinement to handle void messages and check for a registered invoker is a critical change. It's important to ensure that the invoker is not undefined when dispatch is called.

denops/@denops-private/host/nvim.ts (3)
  • 28-28: The addition of the #invoker field to the Neovim class is consistent with the changes made to the Vim class and supports the new message handling logic.

  • 37-54: The modifications in the constructor to use the assigned #invoker for method invocation are significant. It's important to ensure that the #invoker is properly initialized before any invocations are made.

  • 112-112: The change to the register method to assign the invoker to #invoker is a straightforward update that aligns with the PR's objectives.

autoload/denops/_internal/server/chan.vim (1)
  • 100-100: Replacing the direct doautocmd call with s:rpcnotify alters the signaling mechanism, which should ensure that the DenopsReady event is fired at the correct time, as per the PR's objectives.
denops/@denops-private/service.ts (5)
  • 30-37: The inclusion of the readonly meta property in the Service class constructor is a key change that supports the PR's objective to use a single meta instance throughout the service's lifecycle.

  • 49-56: The update to the register method to use this.meta instead of passing meta as an argument simplifies the method signature and is consistent with the PR's objectives.

  • 75-79: The postMessage to the worker now includes meta and trace directly, which is a change that should be verified to ensure that the worker script is expecting these values and handling them correctly.

Verification successful

The shell script results confirm that the worker/script.ts file contains an event listener for messages that deconstructs the event data to obtain scriptUrl, meta, and trace. This indicates that the worker script is indeed expecting these values and has logic in place to handle them.

Based on the provided output, the following can be inferred:

  • The addEventListener for message events is set up to handle incoming data that includes meta and trace.
  • The ensure function is used to validate the structure of the incoming message, which includes meta and trace.
  • The main function is called with scriptUrl, meta, and trace as arguments, with trace having a fallback to false if it is not provided.

Given this information, the review comment concerning the verification of the worker script's handling of meta and trace has been addressed, and it appears that the worker script is correctly handling these values.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the worker script is correctly handling the `meta` and `trace` values passed in the postMessage.
rg --type typescript --files-with-matches 'addEventListener.*message.*meta.*trace'

Length of output: 119



Script:

#!/bin/bash
# Search for the event listener in .ts files that handles messages containing 'meta' and 'trace'
rg 'addEventListener.*message' -g '*.ts' | rg 'meta' | rg 'trace'

Length of output: 63



Script:

#!/bin/bash
# Search for occurrences of 'meta' and 'trace' within the scope of message event handling in .ts files
rg 'addEventListener.*message' -g '*.ts' -C 10 | rg 'meta'
rg 'addEventListener.*message' -g '*.ts' -C 10 | rg 'trace'

Length of output: 532

* 103-111: The update to the `reload` method to use `this.meta` instead of passing `meta` as an argument is consistent with the changes made to the `register` method and supports the PR's objectives.
  • 163-163: The reload dispatcher function now calls service.reload with the skip mode and the trace argument. This change should be verified to ensure that it aligns with the expected behavior when a plugin is reloaded.
autoload/denops/plugin.vim (4)
  • 64-70: The refactoring of denops#plugin#register removes the denops#_internal#meta#get() call and simplifies the handling of the l:options dictionary. Ensure that the removal of meta fetching does not affect any dependent functionality and that the l:options dictionary is correctly populated with the necessary default values.

  • 73-82: The denops#plugin#reload function has been updated to remove the meta parameter. Verify that the new l:args array, which no longer includes meta, is correctly used in the denops#_internal#server#chan#notify call and that all dependent features work as expected without the meta information.

  • 84-93: The denops#plugin#discover function has been refactored to remove the meta parameter. Confirm that the s:register call within the loop correctly handles plugin registration without the meta information and that the default l:options values are appropriate for the discovery process.

  • 134-141: The s:register function has been updated to remove the meta parameter. Ensure that the l:args array is correctly constructed for the denops#_internal#server#chan#notify call and that the removal of meta does not negatively impact the plugin registration process.

doc/denops.txt (1)
  • 90-96: The documentation has been updated to include the new requirement that g:denops#debug must be configured before the denops initialization. This is a breaking change and should be clearly communicated to users. Ensure that the documentation is clear and that there are no other sections that contradict this new requirement.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e91e0a1 and 37bfbfd.
Files selected for processing (8)
  • autoload/denops.vim (1 hunks)
  • autoload/denops/plugin.vim (4 hunks)
  • autoload/denops/server.vim (5 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/service.ts (6 hunks)
  • denops/@denops-private/worker/script.ts (4 hunks)
  • doc/denops.txt (6 hunks)
  • plugin/denops.vim (2 hunks)
Files skipped from review due to trivial changes (1)
  • denops/@denops-private/worker/script.ts
Files skipped from review as they are similar to previous changes (4)
  • autoload/denops/plugin.vim
  • denops/@denops-private/host/invoker.ts
  • denops/@denops-private/service.ts
  • doc/denops.txt
Additional comments: 10
plugin/denops.vim (2)
  • 19-24: The autocmds for DenopsPluginPre, DenopsPluginPost, and DenopsPluginFail have been removed. Ensure that their removal is intentional and that no functionality is lost or needs to be replicated elsewhere.

  • 35-35: The addition of denops#server#wait_async within s:init() is aligned with the PR's objective to improve the initialization process. Ensure that the denops#plugin#discover() callback is correctly implemented and that it will be called once the server is ready.

autoload/denops.vim (1)
  • 30-34: The configuration for denops#trace has been removed. Confirm that this change is consistent with the PR's objectives and that any functionality dependent on this configuration has been appropriately updated or removed.
autoload/denops/server.vim (7)
  • 3-7: The introduction of s:STATUS_PREPARING, s:is_ready, and s:ready_callbacks is consistent with the PR's goal to improve the plugin's initialization process. Verify that these new variables are used correctly throughout the codebase.

  • 74-74: The modification of denops#server#status() to return s:STATUS_PREPARING when s:is_ready is false is a logical change that aligns with the new server status management. Ensure that all calls to denops#server#status() handle the new possible return value correctly.

  • 81-113: The addition of denops#server#wait function is a significant change. Ensure that the function's implementation correctly handles the waiting logic, including the timeout and silent options.

  • 115-121: The denops#server#wait_async function is added to handle asynchronous waiting for server readiness. Confirm that the callback mechanism is correctly implemented and that it integrates well with the rest of the codebase.

  • 135-140: The s:DenopsReady function correctly sets s:is_ready to true and executes all callbacks. Verify that this function is called at the appropriate time to signal readiness.

  • 145-146: The addition of autocmds for User DenopsReady and User DenopsClosed is consistent with the PR's goal to manage server readiness. Ensure that these autocmds are triggered at the correct moments and that their handlers (s:DenopsReady and setting s:is_ready to false) are appropriate.

  • 167-168: The configuration parameters denops#server#wait_interval and denops#server#wait_timeout are introduced. Confirm that these values are sensible defaults and that they are used correctly wherever waiting logic is implemented.

@lambdalisue lambdalisue changed the title 💥 Fix fire timing of DenopsReady and initialization of meta 💥 Minor breaking changes Dec 30, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 405e919 and ee99de0.
Files selected for processing (12)
  • autoload/denops.vim (1 hunks)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/plugin.vim (4 hunks)
  • autoload/denops/server.vim (5 hunks)
  • denops/@denops-private/cli.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (3 hunks)
  • denops/@denops-private/host/vim.ts (4 hunks)
  • denops/@denops-private/service.ts (6 hunks)
  • denops/@denops-private/worker/script.ts (4 hunks)
  • doc/denops.txt (6 hunks)
  • plugin/denops.vim (2 hunks)
Files skipped from review as they are similar to previous changes (10)
  • autoload/denops.vim
  • autoload/denops/_internal/server/chan.vim
  • autoload/denops/plugin.vim
  • autoload/denops/server.vim
  • denops/@denops-private/cli.ts
  • denops/@denops-private/host/invoker.ts
  • denops/@denops-private/host/vim.ts
  • denops/@denops-private/service.ts
  • denops/@denops-private/worker/script.ts
  • plugin/denops.vim
Additional comments: 10
denops/@denops-private/host/nvim.ts (4)
  • 28-28: The addition of the #invoker field to the Neovim class is a significant change. Ensure that the Invoker instance is always set before any invocation occurs to avoid runtime errors.

  • 37-45: The void method is added to the dispatcher to handle void messages. This is a good practice as it explicitly handles cases where no return value is expected.

  • 46-53: The invoke method is updated to use the #invoker field. It is crucial to ensure that this.#invoker is not undefined when this method is called, as it throws an error otherwise. This change centralizes the invoker logic, which is a good practice for maintainability.

  • 112-112: The register method now assigns the invoker to #invoker. This change is part of the refactoring to use the #invoker field within the class. It's important to ensure that register is called before any invocation methods to prevent runtime errors.

doc/denops.txt (6)
  • 93-93: The documentation now specifies that g:denops#debug must be configured before denops initialization. This is an important update that aligns with the code changes and should be clearly communicated to users.

  • 133-139: New variables g:denops#server#wait_interval and g:denops#server#wait_timeout are introduced with default values. This addition provides users with more control over the server wait behavior and should be clearly documented.

  • 229-231: The function denops#server#stop() has been renamed to denops#server#close(). This renaming should be reflected in all parts of the documentation and the codebase to maintain consistency.

  • 250-265: The addition of denops#server#wait() and denops#server#wait_async() functions in the documentation is crucial for users to understand the new synchronous and asynchronous waiting capabilities for the DenopsReady autocmd.

  • 305-324: The documentation marks denops#plugin#register() as deprecated and recommends using denops#plugin#load() instead. It also provides a fallback example for backward compatibility. This is a good practice to ensure smooth transition for users.

  • 327-332: The denops#plugin#discover() function's behavior change is documented. It now loads plugins instead of registering them, which is a significant change that plugin developers need to be aware of.

@lambdalisue lambdalisue marked this pull request as draft December 30, 2023 13:14
@lambdalisue
Copy link
Member Author

It seems tests are broken. I'll fix later

@lambdalisue
Copy link
Member Author

Fixed

@lambdalisue lambdalisue marked this pull request as ready for review December 30, 2023 13:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 405e919 and 4889eae.
Files selected for processing (12)
  • autoload/denops.vim (1 hunks)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/plugin.vim (4 hunks)
  • autoload/denops/server.vim (5 hunks)
  • denops/@denops-private/cli.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (3 hunks)
  • denops/@denops-private/host/vim.ts (4 hunks)
  • denops/@denops-private/service.ts (6 hunks)
  • denops/@denops-private/worker/script.ts (4 hunks)
  • doc/denops.txt (6 hunks)
  • plugin/denops.vim (2 hunks)
Files skipped from review as they are similar to previous changes (11)
  • autoload/denops.vim
  • autoload/denops/_internal/server/chan.vim
  • autoload/denops/plugin.vim
  • autoload/denops/server.vim
  • denops/@denops-private/cli.ts
  • denops/@denops-private/host/invoker.ts
  • denops/@denops-private/host/vim.ts
  • denops/@denops-private/service.ts
  • denops/@denops-private/worker/script.ts
  • doc/denops.txt
  • plugin/denops.vim
Additional comments: 4
denops/@denops-private/host/nvim.ts (4)
  • 28-28: The addition of the #invoker field is consistent with the PR's objective to improve the plugin's initialization process. This field will store the Invoker instance.

  • 37-55: The dispatcher's invoke method is now an async function that asserts the method and arguments, and if the #invoker is set, it calls the corresponding method on the #invoker. This change centralizes the invocation logic and error handling.

  • 112-112: The register method is updated to assign the invoker to the #invoker field. This is a straightforward change that supports the new invocation logic.

  • 42-43: The void method in the dispatcher is a stub that resolves immediately. This seems to be a placeholder for future functionality or a method to satisfy an interface contract.

denops/@denops-private/host/nvim.ts Show resolved Hide resolved
@Shougo
Copy link
Contributor

Shougo commented Dec 31, 2023

The conflict exists.

Previously, the `DenopsReady` autocmd was fired when the channel was
connected.  However, it is not the right timing because the denops
itself may not be ready yet. This commit fixes the timing of the
autocmd so that denops is ready when the autocmd is fired.
This is a minor but a breaking change. This change affects the
`g:denops#debug` variable. After this commit, the variable must
be configured prior to the denops initialization.
It seems `timer_start()` triks is no longer needed so we can call
callbacks synchronously in both cases.
Now developers can wait until the denops is ready to use.
The trace feature is not available when denops liberates from Worker and
the feature obstructs the development of denops.
We are planning to change internal registration mechanism and the
autocmd is not suited for the new mechanism.

Quick search on GitHub shows that the autocmd is not used by anyones.

https://github.com/search?q=DenopsPluginRegister&type=code
We found that developers always use `mode: "skip"` and other options are
not necessary. So we decided to remove `{options}` from functions and
always use `mode: "skip"`.

Quick search revelaed that no one uses `reload` and `discover` with
`{options}` but some (e.g. dein.vim) uses `register` with `{options}`.

That's why we introduced a new `load` function that replaces `register`.

Developers who need to support previous denops should use `load` whenever
possible like:

```vim
try
  call denops#plugin#load(
        \ "denops-hello",
        \ "/path/to/denops-hello/main.ts",
        \)
catch /^Vim\%((\a\+)\)\=:E117:/
  " Fallback to `register` for backward compatibility
  call denops#plugin#register(
        \ "denops-hello",
        \ "/path/to/denops-hello/main.ts",
        \ {"mode": "skip"},
        \)
endtry
```
@Shougo
Copy link
Contributor

Shougo commented Dec 31, 2023

I will test it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b0812d3 and be0bd9b.
Files selected for processing (12)
  • autoload/denops.vim (1 hunks)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/plugin.vim (4 hunks)
  • autoload/denops/server.vim (5 hunks)
  • denops/@denops-private/cli.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (3 hunks)
  • denops/@denops-private/host/vim.ts (4 hunks)
  • denops/@denops-private/service.ts (6 hunks)
  • denops/@denops-private/worker/script.ts (4 hunks)
  • doc/denops.txt (6 hunks)
  • plugin/denops.vim (2 hunks)
Files skipped from review as they are similar to previous changes (11)
  • autoload/denops.vim
  • autoload/denops/_internal/server/chan.vim
  • autoload/denops/plugin.vim
  • autoload/denops/server.vim
  • denops/@denops-private/cli.ts
  • denops/@denops-private/host/invoker.ts
  • denops/@denops-private/host/vim.ts
  • denops/@denops-private/service.ts
  • denops/@denops-private/worker/script.ts
  • doc/denops.txt
  • plugin/denops.vim
Additional comments: 3
denops/@denops-private/host/nvim.ts (3)
  • 28-28: Ensure that #invoker is initialized before any method that relies on it is called to prevent potential runtime errors.
Verification successful

The search results indicate that #invoker is used in several places within vim.ts and nvim.ts. Notably, in nvim.ts, there is a check for this.#invoker === undefined, which suggests that there is a guard to ensure #invoker is not undefined before it is used. This addresses the concern raised in the review comment about ensuring that #invoker is initialized before any method that relies on it is called.

Based on the provided output, the following can be concluded:

  • #invoker is assigned in nvim.ts and vim.ts (lines 77 and 112 respectively).
  • There is a check for undefined in nvim.ts (line 47) before #invoker is used.
  • #invoker is used to dispatch a method in vim.ts (line 36) and to invoke a method in nvim.ts (line 53).

Given this information, it appears that the code has been structured to prevent runtime errors by checking #invoker for undefined before use.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of `#invoker` to ensure it's always checked for undefined before use.
ast-grep --lang typescript --pattern $'this.#invoker.$_($_)'

Length of output: 61



Script:

#!/bin/bash
# Search for any usage of `#invoker` to see if it's being used in any other context or if there are checks for `undefined`.
ast-grep --lang typescript --pattern $'this.#invoker'

Length of output: 455

* 46-53: The addition of the `invoke` method with a check for `#invoker` being undefined is a good practice to ensure that the `Invoker` is registered before invocation.
  • 112-112: The register method correctly assigns the invoker to #invoker, providing a clear initialization point for the Invoker.

denops/@denops-private/host/nvim.ts Show resolved Hide resolved
denops/@denops-private/host/nvim.ts Show resolved Hide resolved
@lambdalisue lambdalisue merged commit 111f4cf into main Jan 2, 2024
16 checks passed
@lambdalisue lambdalisue deleted the fix-denops-ready branch January 2, 2024 11:31
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.

2 participants