假设我在combined.js中有以下(示例)代码
/* jQuery, Moment.js, Bootstrap, etc. */
Child.prototype.doSchool = function(data) { // Bookmarked
var essay = data.essay || {};
if (essay) {
var spelling = checkSpelling(essay, EN_US_GRADE_7);
return spelling.grade();
}
}
/* Extensive and Turing-complete code base */
var burt = new Child();
if (burt.doSchool({essay: "i like trains"}) < .65) burt.comfort(); // Bookmarked
/* jQuery extensions, Fallout 4, etc. */该文件在Komodo 9.3.x中被书签标记为// inline comments标记的位置。
任何/* block comments */都表示数千行代码。
书签之间的源存在于另一个文件school.inc.js中。我想知道是否有一种简单的方法可以在书签之间选择所有文本,这样combined.js就可以轻松地通过粘贴school.inc.js的内容来更新,而不必使用组合实用程序。
发布于 2016-01-12 22:36:15
没有内置的方式来完成这个任务,但是您可以通过编写Userscript来完成它。
您将需要使用Komodo编辑器SDK。
// This assumes you're running the Userscript starting at the first bookmark
var editor = require("ko/editor");
var startSelect;
var endSelect;
var done = false;
function selectBookmarkRegion(){
if(editor.bookmarkExists()) { // check if bookmark is set on current line
startSelect = { // save it's line start
line: editor.getLineNumber(),
ch: 0
};
} else {
alert("Start me on a line with a Bookmark");
}
editor.goLineDown();
while(!done){
if(editor.bookmarkExists())
{
endSelect = {
line: editor.getLineNumber(),
ch: editor.getLineSize()
};// Save line end
done = true;
}
editor.goLineDown();
// found a bug as I was writing this. Will be fixed in the next releases
if (editor.getLineNumber() + 1 == editor.lineCount())
{
done = true;
}
}
editor.setSelection(startSelect, endSelect); // Wrap the selection
}
selectBookmarkRegion();https://stackoverflow.com/questions/34751137
复制相似问题