summaryrefslogtreecommitdiff
path: root/sphinx/directives/code.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r--sphinx/directives/code.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index c9d073abd..85fc28941 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -256,6 +256,8 @@ class LiteralInclude(Directive):
lines = list(diff)
linenostart = self.options.get('lineno-start', 1)
+ if 'lineno-match' in self.options:
+ linenostart = 1
objectname = self.options.get('pyobject')
if objectname is not None:
from sphinx.pycode import ModuleAnalyzer
@@ -294,12 +296,12 @@ class LiteralInclude(Directive):
res = []
for line_number, line in enumerate(lines):
if not use and start_str and start_str in line:
- if 'lineno-match' in self.options:
- linenostart = line_number + 1
if start_inclusive:
res.append(line)
- else:
- linenostart +=1
+ if 'lineno-match' in self.options:
+ linenostart = line_number + 1
+ if not start_inclusive:
+ linenostart += 1
use = True
elif use and end_str and end_str in line:
if end_inclusive: