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

Add a user configuration for the maxoff length #64

Closed
wants to merge 2 commits into from
Closed

Add a user configuration for the maxoff length #64

wants to merge 2 commits into from

Conversation

EdJoJob
Copy link

@EdJoJob EdJoJob commented Jan 9, 2017

Given that the maxoff seems to be a tradeoff between correctness and
performance, allow the user to change it based off their needs.

Closes #63

Given that the maxoff seems to be a tradeoff between correctness and
performance, allow the user to change it based off their needs.
@tbodt
Copy link

tbodt commented Feb 21, 2017

@blueyed Can you merge this?

@blueyed
Copy link
Member

blueyed commented Feb 22, 2017

Given the feedback and the PR itself: should be also increase the default?

What would you use, @EdJoJob and @tbodt?

@tbodt
Copy link

tbodt commented Feb 22, 2017 via email

@blueyed
Copy link
Member

blueyed commented Feb 22, 2017

So I think apart from this PR (which is good in general) we should also bump the default then.. maybe even 200 to be on the safe side?
(I'm not sure how much it impacts performance though)

@EdJoJob
Copy link
Author

EdJoJob commented Feb 22, 2017

I was dealing with an absolutely huge list of dict of dicts at the time so I needed to set it to 500, but I do feel that that would be rather extreme as a default though

@tbodt
Copy link

tbodt commented Feb 22, 2017

Probably a better idea than setting a stopline when calling searchpairpos is to set a timeout of, say, 20ms. That way we don't have to worry either about performance or about setting the number too low.

@tbodt
Copy link

tbodt commented Feb 22, 2017

Actually, it looks like the timeout is not supported on some versions of vim...

@blueyed
Copy link
Member

blueyed commented Feb 22, 2017

We could always assume to have a recent Vim by default, and then maybe fallback to something like 100-200 if the timeout is not supported?

@EdJoJob
Copy link
Author

EdJoJob commented Feb 22, 2017

That is more "normal" in terms of wanting to use newer features, however we in all cases still need an override so that we can deal with 500-1000 line nested structures, uncommon, but absolutely necessary to deal with. If I really needed to I can fix indentation on small (~20 lines) things. I do not have the patience or desire to make sure that my behemoth structure is correct though

@EdJoJob EdJoJob closed this Feb 22, 2017
@EdJoJob
Copy link
Author

EdJoJob commented Feb 22, 2017

oops, wrong button

@EdJoJob EdJoJob reopened this Feb 22, 2017
@blueyed
Copy link
Member

blueyed commented Feb 22, 2017

@EdJoJob
ACK. Can you update the PR to use the timeout feature in Vims that support it, please?
Is 20ms enough there though?

And then the fallback could be 200 lines - but still awaiting more feedback on that though.

@EdJoJob
Copy link
Author

EdJoJob commented Feb 22, 2017

@blueyed I'll have a look through this tonight

@mgedmin
Copy link

mgedmin commented Sep 22, 2017

Why not merge this as-is so people can start using the workaround right away? Perfect is the enemy of good.

@blueyed
Copy link
Member

blueyed commented Sep 22, 2017

@mgedmin
You can use this branch locally.
You are also invited to becoming a member of @Vimjas and then help supporting it.
I rather wait for PRs to be near-perfect, instead of having to fix them myself later.

As for the PR itself: the name in the README does not match the code.. :/

diff --git c/README.rst i/README.rst
index 1c1ffc3..a354999 100644
--- c/README.rst
+++ i/README.rst
@@ -77,8 +77,9 @@ Existing indentation (including ``0``) in multiline strings will be kept, so thi
 python_pep8_indent_max_back_search
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-If you have an error re-indenting a large list or dict set ``g:python_pep8_indent_max_back_search`` to a larger number.
-This defaults to ``50``
+If you have an error re-indenting a large list or dict set
+``g:python_pep8_indent_max_back_search`` to a larger number.
+This defaults to ``50``.
 
 
 Notes
diff --git c/indent/python.vim i/indent/python.vim
index 4278498..0610f00 100644
--- c/indent/python.vim
+++ i/indent/python.vim
@@ -35,12 +35,8 @@ setlocal shiftwidth=4
 if !exists('g:python_pep8_indent_multiline_string')
     let g:python_pep8_indent_multiline_string = 0
 endif
+let s:maxoff = get(g:, 'python_pep8_indent_max_back_search', 50)
 
-if !exists('g:python_pep_8_indent_max_back_search')
-    let s:maxoff = 50
-else
-    let s:maxoff = g:python_pep_8_indent_max_back_search
-endif
 let s:block_rules = {
             \ '^\s*elif\>': ['if', 'elif'],
             \ '^\s*except\>': ['try', 'except'],

I would also prefer to have a basic test for this then.

As for the timeout feature, it could be done in a separate PR, but I think it is better to have it right away and avoid a config setting.

blueyed added a commit that referenced this pull request Sep 22, 2017
The timeout is supported with Vim 7.3.429 at least.

In case of issues (breaking older Vims), this could be wrapped to
fallback to some (higher) max offset.

Fixes #64.
@blueyed blueyed mentioned this pull request Sep 22, 2017
2 tasks
@blueyed
Copy link
Member

blueyed commented Sep 22, 2017

#90

@blueyed
Copy link
Member

blueyed commented Sep 22, 2017

Closing in favor of #90.
Please test if this works for you and report back if 5s is sane (IIRC it gets used in a loop, so might multiply?!)

@blueyed blueyed closed this Sep 22, 2017
blueyed added a commit that referenced this pull request Oct 5, 2017
This uses different offsets for the type of pairs: '()' and '[]' will
only look for just 20 lines above, while 1000 lines are used for '{}',
which might be a huge dict.

Ref: #64.
blueyed added a commit that referenced this pull request Oct 6, 2017
This uses different offsets for the type of pairs: '()' and '[]' will
only look for just 20 lines above, while 1000 lines are used for '{}',
which might be a huge dict.

Ref: #64.
@blueyed
Copy link
Member

blueyed commented Oct 6, 2017

Can you try #91, please?

blueyed added a commit that referenced this pull request Oct 7, 2017
This uses different offsets for the type of pairs: '()' and '[]' will
only look for just 20 lines above, while 1000 lines are used for '{}',
which might be a huge dict.

Ref: #64.
@blueyed
Copy link
Member

blueyed commented Nov 16, 2017

Just for info: #91 is merged as an intermediate fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants