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

Implement dynamic context lines (zooming) #1120

Merged
merged 3 commits into from
Apr 5, 2019
Merged

Conversation

kaste
Copy link
Collaborator

@kaste kaste commented Feb 27, 2019

Fixes #1065

Add [+]/[-] shortcuts to increase or decrease the contextual lines
git diff will output.

Uses the already implemented fuzzy hunk search to place the cursor correctly
after refreshing the view.

Note: We set "--unidiff-zero" when hunking if we do not show any contextual
lines which is otherwise discouraged bc it is mildly unsafe.

Added type annotations and some comments to old functions.

Copy link
Member

@asfaltboy asfaltboy left a comment

Choose a reason for hiding this comment

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

I couldn't make it work on my machine as I assumed it would (going to "regular diff" and hitting +/-) .. it seems to keep the hunks in place while simply changing the hunk line numbers/counts...

I'm not sure I'm doing it right, could you add some description to the implementation please?

common/commands/view_manipulation.py Outdated Show resolved Hide resolved
core/commands/diff.py Outdated Show resolved Hide resolved
@kaste kaste force-pushed the zooming branch 2 times, most recently from c9c046c to 02a6d78 Compare March 4, 2019 12:44
@kaste
Copy link
Collaborator Author

kaste commented Mar 4, 2019

.. it seems to keep the hunks in place while simply changing the hunk line numbers/counts...

Maybe that's what the feature does. It just increases or decreases the contextual lines. E.g. if you press '-' you get more but shorter hunks. But more often you use '+' to see more code.

@kaste
Copy link
Collaborator Author

kaste commented Mar 4, 2019

(GitHub has way more aggressive expanding, they expand by 20 lines if you click in their diff views.)

@@ -18,6 +19,17 @@
from ...common import util


if False:
Copy link
Member

Choose a reason for hiding this comment

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

What's this for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's for 'mypy' typing. mypy will read and import the stuff in the 'False' branch but Sublime's python will not execute this code.

Another way to write this is

MYPY = False
if MYPY:
    ...from typing ...

which is probably just as confusing. @asfaltboy already asked the same question. 😁 but we first have to decide if these type annotations are welcome here at all.

@stoivo
Copy link
Member

stoivo commented Apr 5, 2019

Can you rebase on dev and clean the chage default commit into original.

@kaste kaste force-pushed the zooming branch 2 times, most recently from b5553e1 to 12dbad0 Compare April 5, 2019 13:07
Fixes timbrel#1065

Add `[+]`/`[-]` shortcuts to increase or decrease the contextual lines
`git diff` will output.

Uses the already implemented fuzzy hunk search to place the cursor correctly
after refreshing the view.

Note: We set `"--unidiff-zero"` when hunking if we do not show any contextual
lines which is otherwise discouraged bc it is mildly unsafe.

Added type annotations and some comments to old functions.
@kaste
Copy link
Collaborator Author

kaste commented Apr 5, 2019

Done.

@@ -432,6 +432,46 @@ def setUp(self):
def tearDown(self):
unstub()

@p.expand([
Copy link
Member

@stoivo stoivo Apr 5, 2019

Choose a reason for hiding this comment

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

I'm not to fimiliar with writing these teste what does this do?
Nothing problamatic just think it would be good to know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@p.expand = paramterize the tests

expand takes a list of tuples/args, and will create a separate test for each args/invocation signature.

@stoivo stoivo merged commit 5dcdaaf into timbrel:dev Apr 5, 2019
@kaste kaste deleted the zooming branch April 5, 2019 19:53
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