Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1c0ccb0

Browse files
Vigilansjdneo
authored andcommitted
Bug fix & Prepare for preview markdown webview (leetcode-tools#2)
1 parent ca7487a commit 1c0ccb0

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

‎lib/commands/submit.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,20 @@ cmd.handler = function(argv) {
6666
if (result.ok) {
6767
session.updateStat('ac', 1);
6868
session.updateStat('ac.set', problem.fid);
69-
if (result.runtime_percentile)
70-
printLine(result, 'Your runtime beats %d %% of %s submissions',
71-
result.runtime_percentile.toFixed(2), result.lang);
72-
else
73-
return log.warn('Failed to get runtime percentile.');
74-
if (result.memory && result.memory_percentile)
75-
printLine(result, 'Your memory usage beats %d %% of %s submissions (%s)',
76-
result.memory_percentile.toFixed(2), result.lang, result.memory);
77-
else
78-
return log.warn('Failed to get memory percentile.');
69+
70+
(function () {
71+
if (result.runtime_percentile)
72+
printLine(result, 'Your runtime beats %d %% of %s submissions',
73+
result.runtime_percentile.toFixed(2), result.lang);
74+
else
75+
return log.warn('Failed to get runtime percentile.');
76+
if (result.memory && result.memory_percentile)
77+
printLine(result, 'Your memory usage beats %d %% of %s submissions (%s)',
78+
result.memory_percentile.toFixed(2), result.lang, result.memory);
79+
else
80+
return log.warn('Failed to get memory percentile.');
81+
})();
82+
7983
// core.getSubmission({id: result.id}, function(e, submission) {
8084
// if (e || !submission || !submission.distributionChart)
8185
// return log.warn('Failed to get submission beat ratio.');

‎lib/plugins/cache.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ plugin.getProblem = function(problem, cb) {
2828
const k = h.KEYS.problem(problem);
2929
const _problem = cache.get(k);
3030
if (_problem) {
31-
log.debug('cache hit: ' + k + '.json');
32-
_.extendOwn(problem, _problem);
33-
return cb(null, problem);
31+
// Only hit description with html tags (<pre> always exists for presenting testcase)
32+
if (_problem.desc.includes("<pre>")) {
33+
log.debug('cache hit: ' + k + '.json');
34+
_.extendOwn(problem, _problem);
35+
return cb(null, problem);
36+
}
37+
log.debug('cache discarded for being no longer valid: ' + k + '.json');
3438
}
3539

3640
plugin.next.getProblem(problem, function(e, _problem) {

‎lib/plugins/leetcode.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ plugin.getProblem = function(problem, cb) {
158158
problem.totalAC = JSON.parse(q.stats).totalAccepted;
159159
problem.totalSubmit = JSON.parse(q.stats).totalSubmission;
160160

161-
let content = q.translatedContent ? q.translatedContent : q.content;
162-
// Replace <sup/> with '^' as the power operator
163-
content = content.replace(/<\/sup>/gm, '').replace(/<sup>/gm, '^');
164-
problem.desc = he.decode(cheerio.load(content).root().text());
161+
const content = q.translatedContent ? q.translatedContent : q.content;
162+
// // Replace <sup/> with '^' as the power operator
163+
// content = content.replace(/<\/sup>/gm, '').replace(/<sup>/gm, '^');
164+
// problem.desc = he.decode(cheerio.load(content).root().text());
165+
problem.desc = content;
165166

166167
problem.templates = JSON.parse(q.codeDefinition);
167168
problem.testcase = q.sampleTestCase;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /