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

fix comments behavior on multiple lines with indentation #86 #87

Merged
merged 1 commit into from
Sep 4, 2020
Merged

fix comments behavior on multiple lines with indentation #86 #87

merged 1 commit into from
Sep 4, 2020

Conversation

KeisukeFD
Copy link
Contributor

I tried to improve the comments behaviour on multiple lines, with indentation. Let me know what you think.

Copy link
Owner

@asottile asottile left a comment

Choose a reason for hiding this comment

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

if I'm reading correctly this breaks the following:

    hello
  world
     hello

(select all and :comment)

tests/features/conftest.py Outdated Show resolved Hide resolved
@KeisukeFD
Copy link
Contributor Author

if I'm reading correctly this breaks the following:

    hello
  world
     hello

(select all and :comment)

You right ! I'll try to fix that.

@KeisukeFD
Copy link
Contributor Author

It should be fine now.

Let me know if you see something or have any comments.

babi/file.py Outdated Show resolved Hide resolved
babi/file.py Outdated Show resolved Hide resolved
tests/features/comment_test.py Outdated Show resolved Hide resolved
@KeisukeFD
Copy link
Contributor Author

Hi @asottile,

I tried to fix the behaviour with tabs indentation, should be correct now.
However, I can't make the tests work properly, because for some reason, when I check for '\t' in the await_text, it's completely ignored and replaced by spaces instead.

That's the reason why the code coverage failed in the last check.

@asottile
Copy link
Owner

babi renders tabs as spaces so the expected output should be indentation with spaces (you can save the file and validate the contents to check that tabs are preserved)

@KeisukeFD
Copy link
Contributor Author

Ok !
So I added the tests for tabs (replaced by spaces in the await_text) to have the code coverage corrected.

babi/file.py Outdated Show resolved Hide resolved
@KeisukeFD
Copy link
Contributor Author

Hi @asottile,

I modified the way the comments was implemented before.
But, I don't know why the code coverage is not full yet.. I don't see what test is missing...

@asottile
Copy link
Owner

asottile commented Sep 1, 2020

ah yeah that bit of coverage output is confusing if you haven't seen it before:

babi/file.py     611      0    194      1    99%   709->714

this means that the code never branches from like 709 to line 714

in this case I think it means that one of those if statements is always true in this if-tree: https://github.com/asottile/babi/pull/87/files#diff-682b0b8b14eb28e9e1c8793ac95b28a4R709

I think else: raise AssertionError('unreachable') would fix that

@KeisukeFD
Copy link
Contributor Author

ah yeah that bit of coverage output is confusing if you haven't seen it before:

babi/file.py     611      0    194      1    99%   709->714

this means that the code never branches from like 709 to line 714

in this case I think it means that one of those if statements is always true in this if-tree: https://github.com/asottile/babi/pull/87/files#diff-682b0b8b14eb28e9e1c8793ac95b28a4R709

I think else: raise AssertionError('unreachable') would fix that

Thanks.

@asottile
Copy link
Owner

asottile commented Sep 4, 2020

I fixed up a few things, it was handling this incorrectly:

# foo print('# bar')

it was stripping both of the # characters

I also simplified comment_add (removed all of the logic there)

@asottile asottile merged commit 57bae10 into asottile:master Sep 4, 2020
@asottile asottile mentioned this pull request Sep 5, 2020
@KeisukeFD
Copy link
Contributor Author

I fixed up a few things, it was handling this incorrectly:

# foo print('# bar')

it was stripping both of the # characters

I also simplified comment_add (removed all of the logic there)

Thanks man ! I'll check your modification to see what I did the wrong way. Happy to help !

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