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

👍 remove unnecessary 'foldmethod' changes #271

Merged
merged 2 commits into from
Sep 6, 2024
Merged

Conversation

Milly
Copy link
Contributor

@Milly Milly commented Sep 5, 2024

I also added tests, but I looks like no problem, so I think it's okay to delete these tests.

Summary by CodeRabbit

  • New Features

    • Simplified buffer operations by removing the handling of the foldmethod during append and replace actions.
    • Enhanced test coverage for buffer operations with new test cases focusing on appending and replacing content in buffers with a foldmethod set to "marker".
  • Bug Fixes

    • Improved the reliability of buffer content manipulation by ensuring that the foldmethod remains unchanged during operations.

Copy link

coderabbitai bot commented Sep 5, 2024

Walkthrough

The changes involve modifications to the DenopsStdBufferAppend_${suffix} and DenopsStdBufferReplace_${suffix} functions by removing the handling of the foldmethod buffer option. The previous implementation temporarily altered the foldmethod during execution, which has now been simplified. The documentation and tests have been updated accordingly to ensure clarity and maintain functionality without managing the foldmethod.

Changes

Files Change Summary
buffer/buffer.ts Removed handling of foldmethod in append and replace functions; updated documentation.
buffer/buffer_test.ts Added tests for appending and replacing content in buffers with foldmethod set to "marker".

Poem

🐇 In the meadow, I hop with glee,
Changes made, oh so carefree!
No more folds to fret and bind,
Just simple tasks, a clearer mind.
With each append, my heart takes flight,
Replacing content, all feels right! 🌼


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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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 Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.60%. Comparing base (2ac1b5a) to head (c14d65b).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
- Coverage   84.63%   84.60%   -0.03%     
==========================================
  Files          63       63              
  Lines        3377     3372       -5     
  Branches      291      291              
==========================================
- Hits         2858     2853       -5     
  Misses        517      517              
  Partials        2        2              

☔ 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.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ac1b5a and 079f92a.

Files selected for processing (2)
  • buffer/buffer.ts (5 hunks)
  • buffer/buffer_test.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • buffer/buffer.ts

Comment on lines 305 to 367
await t.step({
name: "appends content of a 'foldmethod=marker' buffer",
fn: async () => {
await denops.cmd("enew");
const bufnr = await fn.bufnr(denops);
await fn.setbufvar(denops, bufnr, "&foldmethod", "marker");
await fn.setbufvar(denops, bufnr, "&foldmarker", "{{{,}}}");
await append(denops, bufnr, [
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
]);
assertEquals([
"",
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
], await fn.getline(denops, 1, "$"));
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);

await fn.setbufvar(denops, bufnr, "&foldlevel", 0);
await append(denops, bufnr, [
"Joking",
]);
assertEquals([
"",
"Joking",
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
], await fn.getline(denops, 1, "$"));
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);

await fn.setbufvar(denops, bufnr, "&foldlevel", 0);
await append(denops, bufnr, [
"Foo",
], {
lnum: 3,
});
assertEquals([
"",
"Joking",
"Hello {{{",
"Foo",
"Darkness",
"My }}}",
"Old friend",
], await fn.getline(denops, 1, "$"));
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);
},
});
Copy link

Choose a reason for hiding this comment

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

Review: New test case for appending content with 'foldmethod=marker'

This test case is well-structured and covers the functionality of appending content to a buffer with the foldmethod set to "marker". It checks both the content of the buffer and the state of the foldmethod after operations, which aligns with the PR's objective to ensure functionality remains intact after removing unnecessary foldmethod changes.

However, the test could be enhanced by verifying the actual folding behavior in the buffer, not just the foldmethod setting. This would ensure that the folding functionality itself is not affected by the changes.

Would you like me to help add assertions to verify the actual folding behavior within the buffer?

Comment on lines 427 to 461
await t.step({
name: "replaces content of an 'foldmethod=marker' buffer",
fn: async () => {
const bufnr = await fn.bufnr(denops);
await fn.setbufvar(denops, bufnr, "&foldmethod", "marker");
await fn.setbufvar(denops, bufnr, "&foldmarker", "{{{,}}}");
await replace(denops, bufnr, [
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
]);
assertEquals([
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
], await fn.getline(denops, 1, "$"));
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);

await fn.setbufvar(denops, bufnr, "&foldlevel", 0);
await replace(denops, bufnr, [
"Joking {{{1",
]);
assertEquals([
"Joking {{{1",
], await fn.getline(denops, 1, "$"));
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);
},
Copy link

Choose a reason for hiding this comment

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

Review: New test case for replacing content with 'foldmethod=marker'

This test case follows a similar structure to the appending test case, focusing on replacing content in a buffer with the foldmethod set to "marker". It effectively verifies that the content and foldmethod setting are correctly handled after the replace operation.

Like the previous test case, it would be beneficial to include checks for the actual folding behavior to ensure that the folding functionality is correctly preserved post-operation.

Would you like assistance in adding checks to verify the actual folding behavior after content replacement in the buffer?

@Milly Milly requested a review from lambdalisue September 5, 2024 08:22
@Milly
Copy link
Contributor Author

Milly commented Sep 5, 2024

Fixes #269

`assertEquals(actual, expected)` is correct.
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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 079f92a and c14d65b.

Files selected for processing (1)
  • buffer/buffer_test.ts (18 hunks)
Additional comments not posted (4)
buffer/buffer_test.ts (4)

Line range hint 27-59: LGTM: Test cases for opening buffers

The test cases for opening buffers are comprehensive and cover a variety of scenarios including remote buffer names and symbols with percent-encoding. The assertions are correctly placed to ensure that the buffer properties are as expected.


Line range hint 106-198: LGTM: Test cases for decoding buffer content

The test cases for decoding buffer content are well-structured and cover various scenarios including different encodings and file formats. The assertions correctly verify that the content and settings are as expected after decoding.


Line range hint 218-303: LGTM: Test cases for appending content to buffers

The test cases for appending content to buffers are comprehensive and check the functionality in both normal and 'unmodifiable' buffers. The assertions are correctly placed to ensure that the content is appended as expected and that buffer properties like 'modifiable' are maintained.


Line range hint 384-460: LGTM: Test cases for replacing content in buffers

The test cases for replacing content in buffers are comprehensive and check the functionality in both normal and 'unmodifiable' buffers, as well as buffers with 'foldmethod=marker'. The assertions are correctly placed to ensure that the content is replaced as expected and that buffer properties like 'modifiable' and 'foldmethod' are maintained.

Comment on lines +306 to +365
name: "appends content of a 'foldmethod=marker' buffer",
fn: async () => {
await denops.cmd("enew");
const bufnr = await fn.bufnr(denops);
await fn.setbufvar(denops, bufnr, "&foldmethod", "marker");
await fn.setbufvar(denops, bufnr, "&foldmarker", "{{{,}}}");
await append(denops, bufnr, [
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
]);
assertEquals(await fn.getline(denops, 1, "$"), [
"",
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
]);
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);

await fn.setbufvar(denops, bufnr, "&foldlevel", 0);
await append(denops, bufnr, [
"Joking",
]);
assertEquals(await fn.getline(denops, 1, "$"), [
"",
"Joking",
"Hello {{{",
"Darkness",
"My }}}",
"Old friend",
]);
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);

await fn.setbufvar(denops, bufnr, "&foldlevel", 0);
await append(denops, bufnr, [
"Foo",
], {
lnum: 3,
});
assertEquals(await fn.getline(denops, 1, "$"), [
"",
"Joking",
"Hello {{{",
"Foo",
"Darkness",
"My }}}",
"Old friend",
]);
assertEquals(
await fn.getbufvar(denops, bufnr, "&foldmethod"),
"marker",
);
Copy link

Choose a reason for hiding this comment

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

Review: Test cases for 'foldmethod=marker' buffer operations

These test cases are crucial for ensuring that the buffer operations do not interfere with the 'foldmethod' settings, especially after the changes made in this PR. The tests verify that the content is appended or replaced correctly and that the 'foldmethod' remains set to "marker".

Suggestions:

  • Verify Actual Folding Behavior: As previously suggested, it would be beneficial to include assertions that verify the actual folding behavior within the buffer. This would ensure that the folding functionality itself is not affected by the changes.
  • Enhance Test Coverage: Consider adding scenarios where the folding might interact differently due to the content changes, such as nested folds or folds that include line breaks.

Would you like assistance in enhancing these tests to cover the suggestions mentioned?

@lambdalisue lambdalisue merged commit afa88b7 into main Sep 6, 2024
10 checks passed
@lambdalisue lambdalisue deleted the remove-foldmethod branch September 6, 2024 06:56
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.

3 participants