Skip to content

Commit

Permalink
[#17] Revert 2 commits
Browse files Browse the repository at this point in the history
This reverts following commits:

cdfe8c7: "[#17] Invoke a command on receiving it from the webview"
cec97cc: "[#17] WIP. Passing command back to the extension"
  • Loading branch information
ryu1kn committed Apr 25, 2019
1 parent cdfe8c7 commit ea79f28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
17 changes: 2 additions & 15 deletions lib/annotation-script-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AnnotationScriptProvider {
const highlightColour = this._configStore.getExtensionConfig('annotationHighlightColor');
/* eslint-disable max-len */
return `
var vscode = acquireVsCodeApi();
var stylesheet = document.styleSheets[0];
var state = {
timeoutId: null,
Expand All @@ -19,7 +18,6 @@ class AnnotationScriptProvider {
document.body.addEventListener('mouseenter', onMouseEnter, true);
document.body.addEventListener('mouseleave', onMouseLeave, true);
document.body.addEventListener('click', onClick, true);
function onMouseEnter(event) {
var el = event.target;
Expand Down Expand Up @@ -59,23 +57,12 @@ class AnnotationScriptProvider {
removeCommitHighlightRuleAndTooltip();
}
function onClick(event) {
event.preventDefault();
var el = event.target;
if (el.className === 'annotation-inner') return sendDiffRequest(el);
}
function sendDiffRequest(lineEl) {
vscode.postMessage(lineEl.getAttribute('data-command'));
}
function addCommitHighlightRuleAndTooltip(annotationEl) {
state.index = 0;
var commitHash = annotationEl.parentNode.getAttribute('data-commitHash');
var commitHash = annotationEl.parentNode.attributes['data-commitHash'].value;
stylesheet.insertRule(createHighlightRule(commitHash), state.index);
var tooltipContents = annotationEl.parentNode.getAttribute('data-details');
var tooltipContents = annotationEl.parentNode.attributes['data-details'].value;
state.tooltipEl = annotationEl.insertAdjacentElement('afterend', createTooltipEl(tooltipContents));
}
Expand Down
12 changes: 0 additions & 12 deletions lib/command/annotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ class AnnotateCommand {
return this._contentProvider.provideTextDocumentContent(uri).then(content => {
panel.webview.html = content;
panel.onDidDispose(() => {}, null, {});
panel.webview.onDidReceiveMessage(
async message => {
try {
const command = JSON.parse(decodeURI(message));
await this._vscode.commands.executeCommand(command.name, ...command.args);
} catch (e) {
console.error(e.stack);
}
},
undefined,
{}
);
});
}).catch(e => this._logger.error(e.stack));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/git-annotation/git-annotation-line-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class GitAnnotationLineBuilder {
get _annotationHtml() {
if (!this._command) return `<div class="annotation-inner">${_.escape(this._caption)}</div>`;

const safeEncodedCommand = this._encodeCommand(this._command);
return `<a href="" data-command="${safeEncodedCommand}" class="annotation-inner">${_.escape(this._caption)}</a>`;
const safeEncodedCommand = this._getUriString(this._command);
return `<a href="${safeEncodedCommand}" class="annotation-inner">${_.escape(this._caption)}</a>`;
}

_encodeCommand(command) {
return encodeURI(JSON.stringify(command));
_getUriString(command) {
return encodeURI(`command:${command.name}?${JSON.stringify(command.args)}`);
}

}
Expand Down

0 comments on commit ea79f28

Please sign in to comment.