Skip to content

Commit

Permalink
feat(default file threshold): Add codeBlockFileNotificationThreshold …
Browse files Browse the repository at this point in the history
…user setting.
  • Loading branch information
Ken Howard committed Jan 3, 2018
1 parent 9352558 commit 233fab6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
"type": "string",
"default": "",
"description": "OAuth Github Token"
},
"gist.codeBlockFileNotificationThreshold": {
"type": "number",
"default": 10,
"description": "Will trigger dialog when opening code block which has more than this number of files."
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/main.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import open = require('open');
import { StorageBlock, StorageService, QuickPickStorageBlock } from '../services/storage.service';
import { insertText } from '../helpers';

const MAX_FILES = workspace.getConfiguration('gist').get<number>('codeBlockFileNotificationThreshold');
export class MainController {

private _provider: StorageService;
Expand Down Expand Up @@ -83,8 +84,8 @@ export class MainController {
const directory = this._createTmpDir(codeBlock.id);
let openSingle = false;

if (Object.keys(codeBlock.files).length > 10) {
openSingle = 'Open Single File' === (await window.showInformationMessage('Selected Block Contains More Than 10 Files.', 'Open Single File', 'Open All'));
if (Object.keys(codeBlock.files).length > MAX_FILES) {
openSingle = 'Open Single File' === (await window.showInformationMessage(`Selected Block Contains More Than ${MAX_FILES} Files.`, 'Open Single File', 'Open All'));
}

if (openSingle) {
Expand Down

0 comments on commit 233fab6

Please sign in to comment.