Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added line counter to the status bar #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This package has two user configurable settings:
- `showGzipInStatusBar`: set to `true` to show calculated gzip size in the status bar. Default is `false`.
- `showBrotli`: set to `true` to show calculated brotli compressed size in the detailed info view. Default is `false`.
- `displayInfoOnTheRightSideOfStatusBar`: set to `true` to show the status bar info on the right side. Default is `false` (left side).
- `showNumberOfLines`: set to `true` to show number of lines in the opened file. Default is `false`.

## Contributing

Expand Down
11 changes: 9 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function updateConfig() {
showGzipInStatusBar: configuration.get('showGzipInStatusBar'),
displayInfoOnTheRightSideOfStatusBar: configuration.get('displayInfoOnTheRightSideOfStatusBar'),
showBrotli: configuration.get('showBrotli'),
showGzipInStatusBar: configuration.get('showGzipInStatusBar')
showGzipInStatusBar: configuration.get('showGzipInStatusBar'),
showNumberOfLines: configuration.get('showNumberOfLines')
};
updateStatusBarItem();
return config;
Expand All @@ -33,6 +34,9 @@ function showStatusBarItem(newInfo) {
info = fzCalculator.addGzipSize(info, config);
statusBarItem.text += ` | Gzip: ${info.gzipSize}`
}
if (config.showNumberOfLines) {
statusBarItem.text += ` | ${newInfo.lineCount}L`
}
statusBarItem.show();
}
}
Expand Down Expand Up @@ -61,8 +65,11 @@ function updateStatusBarItem() {
try {
var currentEditor = window.activeTextEditor.document;
if (currentEditor && currentEditor.uri.scheme === 'file') {
var fileInfo = fzCalculator.loadFileInfoSync(currentEditor.fileName);
fileInfo.lineCount = currentEditor.lineCount;

hideDetailedInfo();
showStatusBarItem(fzCalculator.loadFileInfoSync(currentEditor.fileName));
showStatusBarItem(fileInfo);
} else {
if (currentEditor.uri.scheme !== 'output') hideStatusBarItem();
}
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
"type": "boolean",
"default": false,
"description": "Defaults to false, whether to show the filesize info on the right side of the status bar."
},
"filesize.showNumberOfLines": {
"type": "boolean",
"default": false,
"description": "Defaults to false, whether to show number of lines in the opened file."
}
}
}
Expand Down