Skip to content

Commit 2e720f7

Browse files
authored
Merge pull request #976 from NativeScript/pete/fix-1st-line-extend
fix #975 - wrong 1st line extend
2 parents 52a31b6 + 8a2339e commit 2e720f7

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

test-app/runtime/src/main/cpp/MetadataNode.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,12 @@ bool MetadataNode::GetExtendLocation(string& extendLocation, bool isTypeScriptEx
14811481
return false;
14821482
}
14831483

1484+
// Account for the column length offset added by the addition of the Common JS function wrapper
1485+
// See issue https://github.com/NativeScript/android-runtime/issues/975
1486+
if (lineNumber == 1) {
1487+
column = column - ModuleInternal::MODULE_PROLOGUE_LENGTH;
1488+
}
1489+
14841490
extendLocationStream << fullPathToFile.c_str() << "_" << lineNumber << "_" << column << "_";
14851491
}
14861492
}

test-app/runtime/src/main/cpp/ModuleInternal.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,3 +490,4 @@ jmethodID ModuleInternal::RESOLVE_PATH_METHOD_ID = nullptr;
490490

491491
const char* ModuleInternal::MODULE_PROLOGUE = "(function(module, exports, require, __filename, __dirname){ ";
492492
const char* ModuleInternal::MODULE_EPILOGUE = "\n})";
493+
int ModuleInternal::MODULE_PROLOGUE_LENGTH = std::string(ModuleInternal::MODULE_PROLOGUE).length();

test-app/runtime/src/main/cpp/ModuleInternal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class ModuleInternal {
3434
* Used before initializing workers, to ensure a thread will not be created, when the file doesn't exist
3535
*/
3636
static void CheckFileExists(v8::Isolate* isolate, const std::string& path, const std::string& baseDir);
37+
38+
static int MODULE_PROLOGUE_LENGTH;
3739
private:
3840
enum class ModulePathKind;
3941

0 commit comments

Comments
 (0)