Skip to content

Commit 20505cf

Browse files
committed
fix(mainpanel) show main panel for tsconfig.json
1 parent 5eb8eb1 commit 20505cf

File tree

4 files changed

+49
-11
lines changed

4 files changed

+49
-11
lines changed

dist/main/atom/atomUtils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ function onDiskAndTs(editor) {
3838
return false;
3939
}
4040
exports.onDiskAndTs = onDiskAndTs;
41+
function onDiskAndTsRelated(editor) {
42+
if (editor instanceof require('atom').TextEditor) {
43+
var filePath = editor.getPath();
44+
if (!filePath) {
45+
return false;
46+
}
47+
var ext = path.extname(filePath);
48+
if (isAllowedExtension(ext)) {
49+
if (fs.existsSync(filePath)) {
50+
return true;
51+
}
52+
}
53+
if (filePath.endsWith('tsconfig.json')) {
54+
return true;
55+
}
56+
}
57+
return false;
58+
}
59+
exports.onDiskAndTsRelated = onDiskAndTsRelated;
4160
function getFilePathPosition() {
4261
var editor = atom.workspace.getActiveTextEditor();
4362
var filePath = editor.getPath();

dist/main/atomts.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exports.config = atomConfig.schema;
2626
var utils_1 = require("./lang/utils");
2727
var hideIfNotActiveOnStart = utils_1.debounce(function () {
2828
var editor = atom.workspace.getActiveTextEditor();
29-
if (!atomUtils.onDiskAndTs(editor)) {
29+
if (!atomUtils.onDiskAndTsRelated(editor)) {
3030
mainPanelView.hide();
3131
}
3232
}, 100);
@@ -60,6 +60,9 @@ function readyToActivate() {
6060
mainPanelView.panelView.updateFileStatus(filePath);
6161
mainPanelView.show();
6262
}
63+
else if (atomUtils.onDiskAndTsRelated(editor)) {
64+
mainPanelView.show();
65+
}
6366
else {
6467
mainPanelView.hide();
6568
}
@@ -114,14 +117,6 @@ function readyToActivate() {
114117
});
115118
var buffer = editor.buffer;
116119
var fasterChangeObserver = editor.buffer.onDidChange(function (diff) {
117-
//// For debugging
118-
// console.log(buffer.characterIndexForPosition(diff.oldRange.start), buffer.characterIndexForPosition(diff.oldRange.end), diff.oldText,
119-
// buffer.characterIndexForPosition(diff.newRange.start), buffer.characterIndexForPosition(diff.newRange.end), diff.newText);
120-
//// Examples
121-
//// 20 20 "aaaa" 20 20 ""
122-
//// 23 23 "" 23 24 "a"
123-
//// 20 20 "" 20 24 "aaaa"
124-
// stack();
125120
var newText = diff.newText;
126121
var oldText = diff.oldText;
127122
var start = { line: diff.oldRange.start.row, col: diff.oldRange.start.column };

lib/main/atom/atomUtils.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ export function onDiskAndTs(editor: AtomCore.IEditor) {
4343
return false;
4444
}
4545

46+
/** Either ts or tsconfig */
47+
export function onDiskAndTsRelated(editor: AtomCore.IEditor) {
48+
if (editor instanceof require('atom').TextEditor) {
49+
var filePath = editor.getPath();
50+
if (!filePath) {
51+
return false;
52+
}
53+
var ext = path.extname(filePath);
54+
if (isAllowedExtension(ext)) {
55+
if (fs.existsSync(filePath)) {
56+
return true;
57+
}
58+
}
59+
if (filePath.endsWith('tsconfig.json')) {
60+
return true;
61+
}
62+
}
63+
return false;
64+
}
65+
4666
export function getFilePathPosition(): { filePath: string; position: number } {
4767
var editor = atom.workspace.getActiveTextEditor();
4868
var filePath = editor.getPath();

lib/main/atomts.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {debounce} from "./lang/utils";
5252
var hideIfNotActiveOnStart = debounce(() => {
5353
// Only show if this editor is active:
5454
var editor = atom.workspace.getActiveTextEditor();
55-
if (!atomUtils.onDiskAndTs(editor)) {
55+
if (!atomUtils.onDiskAndTsRelated(editor)) {
5656
mainPanelView.hide();
5757
}
5858
}, 100);
@@ -122,7 +122,11 @@ function readyToActivate() {
122122

123123
mainPanelView.panelView.updateFileStatus(filePath);
124124
mainPanelView.show();
125-
} else {
125+
}
126+
else if (atomUtils.onDiskAndTsRelated(editor)){
127+
mainPanelView.show();
128+
}
129+
else {
126130
mainPanelView.hide();
127131
}
128132
});

0 commit comments

Comments
 (0)