Skip to content

Commit

Permalink
Fix workspace string length bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nevesnunes committed Mar 20, 2016
1 parent 7e7ed6f commit c709c20
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function runFilter(app, fragment) {
let score = 0;
const descriptionLowerCase = description(app).toLowerCase();
const filteredDescription = descriptionLowerCase
.slice(descriptionNameIndex(), descriptionLowerCase.length);
.slice(descriptionNameIndex(app), descriptionLowerCase.length);

// go through each match inside description
while ((match = regexp.exec(filteredDescription))) {
Expand Down Expand Up @@ -173,9 +173,13 @@ function description(app) {
return workspace + appName + ' → ' + app.get_title();
}

function descriptionNameIndex() {
// note, this doesn't work correctly when there are more 9 workspaces
return (Convenience.getSettings().get_boolean('workspace-indicator')) ? 3 : 0;
function descriptionNameIndex(app) {
if (Convenience.getSettings().get_boolean('workspace-indicator')) {
const workspace = (app.get_workspace().index() + 1);
return workspace.toString().length + 2;
} else {
return 0;
}
}

function escapeChars(text) {
Expand Down

0 comments on commit c709c20

Please sign in to comment.