File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var utils = require('./utils');
6
6
function Code ( str , comment ) {
7
7
str = utils . restore ( str ) ;
8
8
var start = comment . loc . end . pos ;
9
- var lineno = comment . loc . end . line + 1 ;
9
+ var lineno = comment . loc . end . line ;
10
10
var ctx = { } ;
11
11
12
12
var lines = str . split ( '\n' ) . slice ( lineno ) ;
Original file line number Diff line number Diff line change @@ -151,6 +151,18 @@ describe('code', function() {
151
151
assert . equal ( actual [ 0 ] . code . value , 'var foo = "bar";' ) ;
152
152
} ) ;
153
153
154
+ it ( 'should get a code line that immediately follows the comment' , function ( ) {
155
+ var str = '/**\n * this is\n *\n * a comment\n*/\nvar foo = "bar";\n// var one = two' ;
156
+ var actual = extract ( str ) ;
157
+ assert . equal ( actual [ 0 ] . code . value , 'var foo = "bar";' ) ;
158
+ } ) ;
159
+
160
+ it ( 'should not get a comment following a comment' , function ( ) {
161
+ var str = '/**\n * this is\n *\n * a comment\n*/\n// var one = two' ;
162
+ var actual = extract ( str ) ;
163
+ assert . equal ( actual [ 0 ] . code . value , '' ) ;
164
+ } ) ;
165
+
154
166
it ( 'should get the code starting and ending indices' , function ( ) {
155
167
var str = '/**\n * this is\n *\n * a comment\n*/\n\n\nvar foo = "bar";\n' ;
156
168
var actual = extract ( str ) ;
You can’t perform that action at this time.
0 commit comments