diff --git a/plugins/org.python.pydev.core/src/org/python/pydev/core/docstrings/AssistDocString.java b/plugins/org.python.pydev.core/src/org/python/pydev/core/docstrings/AssistDocString.java index 95a2dff085..fbf3b38f47 100644 --- a/plugins/org.python.pydev.core/src/org/python/pydev/core/docstrings/AssistDocString.java +++ b/plugins/org.python.pydev.core/src/org/python/pydev/core/docstrings/AssistDocString.java @@ -74,7 +74,6 @@ public List getProps(PySelection ps, IImageCache imag } } List params = tuple.contents; - int lineOfOffset = ps.getLineOfOffset(tuple.closeParenthesisOffset); // Calculate only the initial part of the docstring here (everything else should be lazily computed on apply). String initial = PySelection.getIndentationFromLine(ps.getCursorLineContents()); @@ -90,6 +89,7 @@ public List getProps(PySelection ps, IImageCache imag buf.append(delimiterAndIndent); int newOffset = buf.length(); + int lineOfOffset = ps.getLineOfOffset(tuple.closeParenthesisOffset); int offsetPosToAdd = ps.getEndLineOffset(lineOfOffset); IImageHandle image = null; //may be null (testing) @@ -99,8 +99,7 @@ public List getProps(PySelection ps, IImageCache imag final boolean inFunctionLine = ps.isInFunctionLine(true); DocstringInfo docstringFromFunction = null; if (inFunctionLine) { - int currLine = ps.getLineOfOffset(); - docstringFromFunction = ps.getDocstringFromLine(currLine + 1); + docstringFromFunction = ps.getDocstringFromLine(lineOfOffset + 1); } final DocstringInfo finalDocstringFromFunction = docstringFromFunction; String preferredDocstringStyle = AssistDocString.this.docStringStyle; diff --git a/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/AssistDocStringTest.java b/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/AssistDocStringTest.java index b82cd90c8c..da2f835005 100644 --- a/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/AssistDocStringTest.java +++ b/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/AssistDocStringTest.java @@ -133,13 +133,40 @@ public void testApplyGoogle1() throws Exception { public void testApplyGoogle2() throws Exception { String expected; - expected = " def foo(self): #comment\r\n" + - " '''\r\n" + - " \r\n" + - " '''"; + expected = """ + def foo(self): #comment + ''' + .... + '''\ + """.replace("....", " "); checkGoogle(expected, " def foo(self): #comment", 1); } + public void testUpdateDocstringGoogleRequest() throws Exception { + String expected; + expected = """ + def foo( + self, + a, + b): + ''' + Args: + a: + b: + ''' + """; + checkGoogle(expected, """ + def foo( + self, + a, + b): + ''' + Args: + a: + ''' + """, 1); + } + public void testApply() throws Exception { String expected; expected = "def foo(a): #comment\r\n" +