Skip to content

Commit d663d4e

Browse files
committed
chore: spanner status icon if there are fixes available
1 parent 7fd76b9 commit d663d4e

5 files changed

Lines changed: 40 additions & 8 deletions

File tree

src/language/CodeInspection.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,14 @@ define(function (require, exports, module) {
381381

382382
$problemsPanel.find(".title").text(message);
383383
tooltip = StringUtils.format(Strings.STATUSBAR_CODE_INSPECTION_TOOLTIP, message);
384-
StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-errors", tooltip);
384+
let iconType = "inspection-errors";
385+
if(documentFixes.size){
386+
tooltip = StringUtils.format(Strings.STATUSBAR_CODE_INSPECTION_TOOLTIP_WITH_FIX,
387+
documentFixes.size, message);
388+
iconType = "inspection-repair";
389+
}
390+
391+
StatusBar.updateIndicator(INDICATOR_ID, true, iconType, tooltip);
385392
}
386393

387394
function _getMarkOptions(error){
@@ -503,6 +510,8 @@ define(function (require, exports, module) {
503510
let codeInspectionMarks = editor.findMarksAt(pos, CODE_MARK_TYPE_INSPECTOR) || [];
504511
let $hoverMessage = $(`<div class="code-inspection-item"></div>`);
505512
let $problemView, quickViewPresent;
513+
let startPos = {line: pos.line, ch: token.start},
514+
endPos = {line: pos.line, ch: token.end};
506515
for(let mark of codeInspectionMarks){
507516
quickViewPresent = true;
508517
const fixID = `${mark.metadata}`;
@@ -525,11 +534,24 @@ define(function (require, exports, module) {
525534
toggleCollapsed(false);
526535
_scrollToTableLine(pos.line);
527536
});
537+
const markPos = mark.find();
538+
if(markPos.from && markPos.from.line < startPos.line){
539+
startPos.line = markPos.from.line;
540+
}
541+
if(markPos.from && markPos.from.ch < startPos.ch){
542+
startPos.ch = markPos.from.ch;
543+
}
544+
if(markPos.to && markPos.to.line > endPos.line){
545+
endPos.line = markPos.to.line;
546+
}
547+
if(markPos.to && markPos.to.ch > endPos.ch){
548+
endPos.ch = markPos.to.ch;
549+
}
528550
}
529551
if(quickViewPresent){
530552
resolve({
531-
start: {line: pos.line, ch: token.start}, // tod this should not be of the token
532-
end: {line: pos.line, ch: token.end},
553+
start: startPos,
554+
end: endPos,
533555
content: $hoverMessage
534556
});
535557
return;

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ define({
396396
"STATUSBAR_INSOVR_TOOLTIP": "Click to toggle cursor between Insert (INS) and Overwrite (OVR) modes",
397397
"STATUSBAR_LANG_TOOLTIP": "Click to change file type",
398398
"STATUSBAR_CODE_INSPECTION_TOOLTIP": "{0}. Click to toggle report panel.",
399+
"STATUSBAR_CODE_INSPECTION_TOOLTIP_WITH_FIX": "{0} Problem fixable. {1}. Click to toggle report panel.",
399400
"STATUSBAR_DEFAULT_LANG": "(default)",
400401
"STATUSBAR_SET_DEFAULT_LANG": "Set as Default for .{0} Files",
401402
"STATUSBAR_ENCODING_TOOLTIP": "Select the encoding",

src/styles/brackets.less

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,7 +2885,7 @@ textarea.exclusions-editor {
28852885
cursor: default;
28862886
width: 13px;
28872887

2888-
&.inspection-errors {
2888+
&.inspection-errors, &.inspection-repair {
28892889
cursor: pointer;
28902890
}
28912891
}
@@ -2898,11 +2898,15 @@ textarea.exclusions-editor {
28982898
background: url(images/topcoat-warning-15.svg) 9px 5px no-repeat;
28992899
}
29002900

2901-
.inspection-errors:hover {
2901+
.inspection-repair {
2902+
background: url(images/topcoat-repair-15.svg) 9px 5px no-repeat;
2903+
}
2904+
2905+
.inspection-errors:hover, .inspection-repair:hover {
29022906
background-color: rgba(0, 0, 0, 0.03);
29032907
}
29042908

2905-
.inspection-errors:active {
2909+
.inspection-errors:active, .inspection-repair:active {
29062910
background-color: rgba(0, 0, 0, 0.05);
29072911
}
29082912

Lines changed: 3 additions & 0 deletions
Loading

test/spec/PreferencesManager-integ-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ define(function (require, exports, module) {
102102
// there will be an error in problems panel if both present
103103
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".phcode.json"));
104104
await awaitsFor(()=>{
105-
return testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
105+
return testWindow.$("#problems-panel").is(":visible") &&
106+
testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
106107
}, "problem panel on .phcode.json");
107108

108109
await awaitsForDone(SpecRunnerUtils.openProjectFiles("test.json"));
@@ -112,7 +113,8 @@ define(function (require, exports, module) {
112113

113114
await awaitsForDone(SpecRunnerUtils.openProjectFiles(".brackets.json"));
114115
await awaitsFor(()=>{
115-
return testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
116+
return testWindow.$("#problems-panel").is(":visible") &&
117+
testWindow.$("#problems-panel").text().includes(Strings.ERROR_PREFS_PROJECT_LINT_MESSAGE);
116118
}, "problem panel on .brackets.json");
117119
});
118120

0 commit comments

Comments
 (0)