-
Notifications
You must be signed in to change notification settings - Fork 1
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
Avoid using this
at all costs
#6
Avoid using this
at all costs
#6
Conversation
WalkthroughThis set of changes refactors the code in the Denops Aider project to improve clarity and maintainability. Key updates include shifting method calls from context-dependent references (using Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AiderCommand
participant Buffer
User->>AiderCommand: addCurrentFile()
AiderCommand->>Buffer: run(denops)
Buffer-->>AiderCommand: Process complete
AiderCommand-->>User: Result
User->>AiderCommand: addWeb()
AiderCommand->>Buffer: sendPromptWithInput(denops)
Buffer-->>AiderCommand: Input sent
AiderCommand-->>User: Result
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- denops/aider/aiderCommand.ts (1 hunks)
- denops/aider/buffer.ts (6 hunks)
- denops/aider/main.ts (2 hunks)
Files skipped from review due to trivial changes (1)
- denops/aider/main.ts
Additional comments not posted (7)
denops/aider/aiderCommand.ts (1)
39-39
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
aiderCommand
object enhances readability and ensures consistent method invocation.denops/aider/buffer.ts (6)
125-125
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
buffer
object enhances readability and ensures consistent method invocation.
139-139
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
buffer
object enhances readability and ensures consistent method invocation.
152-152
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
buffer
object enhances readability and ensures consistent method invocation.
216-221
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
buffer
object enhances readability and ensures consistent method invocation.
232-233
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
buffer
object enhances readability and ensures consistent method invocation.
267-267
: LGTM! The change improves clarity and avoids potential issues withthis
.Explicitly referencing the
buffer
object enhances readability and ensures consistent method invocation.
c763cb5
to
dbe0869
Compare
@tsukimizake |
@@ -42,15 +42,15 @@ export async function main(denops: Denops): Promise<void> { | |||
} | |||
const prompt = `/add ${path}`; | |||
await v.r.set(denops, "q", prompt); | |||
await this.sendPromptWithInput(); | |||
await denops.dispatcher.sendPromptWithInput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この書き方できるんだ…。
すべてがオブジェクトだからできるのか 🤔
@tsukimizake |
thisの扱いはjs/tsの各種複雑怪奇な謎仕様の中でも最も正気を失っている部分で、thisは定義時のオブジェクトを指すとは限らず、呼び出したタイミングの文脈で決まります。
具体的には関数がコールバックとして渡されて
f
などの名前にバインドされ、buffer.
やaiderCommand.
などのプレフィクスなしで呼び出された場合、その関数内のthisはたぶんundefinedになります。https://zenn.dev/convers39/articles/e0b7a26859f999 このあたり参考文献としてたぶん良さそうです(無駄に複雑かつ全体的にただのバグもいいところであり、知っていても一切役に立たないので私もすべて理解しているわけではないです)
thisには触れたら負けであると思ってください
Summary by CodeRabbit
Refactor
Bug Fixes