Skip to content

Commit

Permalink
resolve #15, this is not a bug related to this extension actually,but…
Browse files Browse the repository at this point in the history
… I workout by hack for now see microsoft/vscode#586
  • Loading branch information
wayou committed Mar 1, 2017
1 parent 161c67d commit b5b486f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 0.4.2 - 2017-03-01
- fix #15 links in outputh channel not clickable on windows

## 0.4.1 - 2017-03-01
- list annotations into the outputchannel instead of the quickpick panel, resolve #13
- store search result into workspaceState, using the status bar item to show the result at any time
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"keyword",
"annotation"
],
"version": "0.4.1",
"version": "0.4.2",
"publisher": "wayou",
"license": "MIT",
"icon": "assets/icon.png",
Expand Down
58 changes: 18 additions & 40 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,17 @@ function searchAnnotationInFile(file, annotations, annotationList, regexp) {
annotations[pathWithoutFile] = [];
}
var content = getContent(lineText, match);
var locationInfo = getLocationInfo(pathWithoutFile, lineText, line, match);
if (content.length > 500) {
content = content.substring(0, 500).trim() + '...';
}
var locationInfo = getLocationInfo(fileInUri, pathWithoutFile, lineText, line, match);

var annotation = {
// description: locationInfo.location,
uri: locationInfo.uri,
label: content,
detail: locationInfo.location,
detail: locationInfo.relativePath,
lineNum: line,
fileName: locationInfo.fileName,
fileName: locationInfo.absPath,
startCol: locationInfo.startCol,
endCol: locationInfo.endCol
};
Expand Down Expand Up @@ -145,46 +148,20 @@ function annotationsFound(err, annotationType, annotations, annotationList) {

showOutputChannel(annotationList);

// window.showQuickPick(annotationList, {}).then(function (response) {
// if (!response) return;
// var nameSplit = String(response.fileName);
// var file = 'file://' + nameSplit;
// var fileUri = vscode.Uri.parse(file);
// workspace.openTextDocument(fileUri).then(function (textDocument) {
// window.showTextDocument(textDocument, vscode.ViewColumn.One).then(function (textEditor) {
// var lineNum = response.lineNum;
// var resultObjects = annotations[nameSplit];
// var startPos;
// var endPos;
// for (var i = 0; i < resultObjects.length; i++) {
// var object = resultObjects[i];
// if (object.lineNum === lineNum) {
// startPos = new vscode.Position(object.lineNum, response.startCol);
// endPos = new vscode.Position(object.lineNum, response.endCol);
// break;
// }
// }
// var newSelection = new vscode.Selection(startPos, endPos);
// window.activeTextEditor.selection = newSelection;
// window.activeTextEditor.revealRange(newSelection, vscode.TextEditorRevealType.Default);
// }, function (err) {
// errorHandler(err);
// });
// }, function (err) {
// errorHandler(err);
// });
// }, function (err) {
// errorHandler(err);
// });

}

function showOutputChannel(data) {
if (!window.outputChannel) return;

window.outputChannel.clear();
data.forEach(function (v, i, a) {
window.outputChannel.appendLine(v.fileName + ':' + (v.lineNum + 1) + ':' + (v.startCol + 1));
//for mac
// window.outputChannel.appendLine('#' + (i + 1) + '\t' + v.uri + ':' + (v.lineNum + 1) + ':' + (v.startCol + 1));
//for windows
// window.outputChannel.appendLine('#' + (i + 1) + '\t' + v.uri + '#' + (v.lineNum + 1));
// NOTE: try for both. THIS WORKS!!!
// deu to this bug https://github.com/Microsoft/vscode/issues/586, behavior of output pannel differs from mac and windows. on mac the link should be xxxx:row:col while on windows is xxx#row. and I tried combine both to make it work on both os
window.outputChannel.appendLine('#' + (i + 1) + '\t' + v.uri + '#' + (v.lineNum + 1)+ ':' + (v.lineNum + 1) + ':' + (v.startCol + 1));
window.outputChannel.appendLine(v.label + '\n');
});
window.outputChannel.show();
Expand All @@ -210,16 +187,17 @@ function getContent(lineText, match) {
return lineText.substring(lineText.indexOf(match[0]), lineText.length);
};

function getLocationInfo(pathWithoutFile, lineText, line, match) {
function getLocationInfo(fileInUri, pathWithoutFile, lineText, line, match) {
var rootPath = workspace.rootPath + '/';
var outputFile = pathWithoutFile.replace(rootPath, '');
var startCol = lineText.indexOf(match[0]);
var endCol = lineText.length;
var location = outputFile + ' ' + (line + 1) + ':' + (startCol + 1);

return {
fileName: pathWithoutFile,
location: location,
uri: fileInUri,
absPath: pathWithoutFile,
relativePath: location,
startCol: startCol,
endCol: endCol
};
Expand Down
Binary file removed vscode-todo-highlight-0.4.1.vsix
Binary file not shown.

0 comments on commit b5b486f

Please sign in to comment.