Skip to content
Permalink
Browse files

realtime spelling: pr feedback, some small fixes

  • Loading branch information...
adamconroy committed Aug 20, 2019
1 parent 7fce011 commit 97af0035e8d027237144326dae5689192487b15f
@@ -94,8 +94,8 @@ class HunspellDictionaryManager
private:
core::FilePath allLanguagesDir() const;
core::FilePath customLanguagesDir() const;
core::FilePath old_allLanguagesDir() const;
core::FilePath old_customLanguagesDir() const;
core::FilePath legacyAllLanguagesDir() const;
core::FilePath legacyCustomLanguagesDir() const;

private:
core::FilePath coreLanguagesDir_;
@@ -195,7 +195,7 @@ const HunspellCustomDictionaries& HunspellDictionaryManager::custom() const
* \deprecated
* For getting all languages from pre-1.3 RStudio
* */
FilePath HunspellDictionaryManager::old_allLanguagesDir() const
FilePath HunspellDictionaryManager::legacyAllLanguagesDir() const
{
return userDir_.childPath("languages-system");
}
@@ -204,7 +204,7 @@ FilePath HunspellDictionaryManager::old_allLanguagesDir() const
* \deprecated
* For getting user languages from pre-1.3 RStudio
* */
FilePath HunspellDictionaryManager::old_customLanguagesDir() const
FilePath HunspellDictionaryManager::legacyCustomLanguagesDir() const
{
return userDir_.childPath("custom");
}
@@ -97,7 +97,7 @@ core::spelling::HunspellDictionaryManager hunspellDictionaryManager()
* \deprecated
* For getting all languages from pre-1.3 RStudio
* */
FilePath old_allLanguagesDir()
FilePath legacyAllLanguagesDir()
{
return module_context::userScratchPath().childPath( "dictionaries/languages-system");
}
@@ -106,7 +106,7 @@ FilePath old_allLanguagesDir()
* \deprecated
* For getting custom languages from pre-1.3 RStudio
* */
FilePath old_customDictionariesDir()
FilePath legacyCustomDictionariesDir()
{
return module_context::userScratchPath().childPath( "dictionaries/custom");
}
@@ -146,18 +146,17 @@ void handleDictionaryRequest(const http::Request& request, http::Response* pResp
{
pResponse->setCacheableFile(allLanguagesDir().complete(splat[1]), request);
}

/*
* \deprecated
* Calls to old deprecated dictionary locations for RStudio 1.2 and earlier
*/
if (old_customDictionariesDir().complete(splat[1]).exists())
else if (legacyCustomDictionariesDir().complete(splat[1]).exists())
{
pResponse->setCacheableFile(old_customDictionariesDir().complete(splat[1]), request);
pResponse->setCacheableFile(legacyCustomDictionariesDir().complete(splat[1]), request);
}
else if (old_allLanguagesDir().complete(splat[1]).exists())
else if (legacyAllLanguagesDir().complete(splat[1]).exists())
{
pResponse->setCacheableFile(old_allLanguagesDir().complete(splat[1]), request);
pResponse->setCacheableFile(legacyAllLanguagesDir().complete(splat[1]), request);
}
else if (options().hunspellDictionariesPath().complete(splat[1]).exists())
{
@@ -125,7 +125,7 @@ var MarkdownHighlightRules = function() {
};

var linkByUrl = {
token : ["text", "keyword", "text", "markup.href", "string", "text", "paren.keyword.operator", "nospell", "paren.keyword.operator"],
token : ["text", "keyword", "text", "markup.href", "string", "text", "nospell", "paren.keyword.operator"],
regex : "(\\s*\\[)(" + // [
escaped("]") + // link text
")(\\]\\()" + // ](
@@ -219,7 +219,8 @@ void initialize(SpellingService spellingService, WorkbenchListManager workbenchL
if (domainSpecificWords_.isEmpty())
{
String[] words = RES.domainSpecificWords().getText().split("[\\r\\n]+");
for (String w : words){
for (String w : words)
{
if (w.length() > 0)
domainSpecificWords_.add(w.toLowerCase());
}
@@ -375,9 +376,10 @@ public boolean shouldCheckSpelling(DocDisplay dd, Range r)
if (s.isYaml())
return false;

// Don't spellcheck untokenized words inside a keyword scope
// This will capture all blocked text in a way that the highlight rules
// don't and shouldn't
String line = dd.getLine(r.getStart().getRow());
Pattern p = Pattern.create("\\\\(?:documentclass|usepackage|newcounter|setcounter|addtocounter|value|arabic|stepcounter|newenvironment|renewenvironment|ref|vref|eqref|pageref|label|cite[a-zA-Z]*|tag|begin|end|bibitem).*{.*" + word + ".*}");
Pattern p = Pattern.create("\\{.*" + word + ".*\\}");
if (p.test(line))
return false;

@@ -1,13 +1,10 @@
abind
acknowledgements
acyclic
addin
addins
afl
alphabetises
altrep
altrepisode
amongst
analytics
api
applypatch
@@ -23,7 +20,6 @@ az
backports
backslashed
bcp
behaviour
benchmarking
bg
biblatex
@@ -43,10 +39,7 @@ bugfixes
bugreports
bz
bzip
cancelled
catalogue
ccby
centric
chriswhong
ci
cifs
@@ -59,11 +52,6 @@ cmd
cn
codecov
coercible
colour
coloured
colouring
colourised
colours
config
cpp
cran
@@ -83,7 +71,6 @@ devtools
dir
dircolors
disqus
distill's
dockerhub
docsearch
doi
@@ -98,7 +85,6 @@ emacs
env
envvar
eo
errors
et
etag
etags
@@ -133,7 +119,6 @@ getgrent
getpwent
ggplot
gists
git's
github
gitignore
gitignores
@@ -163,10 +148,6 @@ ides
ietf
iframe
igraph
initialisation
initialise
initialises
initialising
inode
installable
instapaper
@@ -183,22 +164,19 @@ json
jupyter
ka
kalibera
keychain
kh
kib
kk
knitr
ko
kr
labelled
lbzip
learnr
lexicographically
lgl
libbsd
libgit
libuv
lifecycle
linkedin
linkingto
linters
@@ -217,26 +195,22 @@ macos
magrittr
magrittr's
mainfont
maintainer's
makefile
makefiles
mandreyel
mathfont
md
metadata
microtype
minimise
mio
misspecify
mk
mn
modelled
monofont
morem
msg
mtcars
multithreaded
nano
natbib
natively
navbar
@@ -247,24 +221,20 @@ nfs
nl
nodejs
noncentral
notes
nulls
numpy
nyc
nycflights
objs
oneside
only’
openssl
orcid
organisation
organisations
ostype
pagedown
pageins
pak's
pak’s
pak
pandoc
parser
parsers
pats
pdf
@@ -290,7 +260,6 @@ pthread
pubkey
purrr
px
r's
Rademacher
rchk
rcpp
@@ -301,19 +270,13 @@ rds
readline
readme
readr
realisation
rebase
recognised
recurse
redirections
renviron
repl
repo
repo's
report
repos
reprex
reproducibility
restructing
retryable
revdep
@@ -356,7 +319,6 @@ sigcont
sigkill
signalling
sitrep
situation
sk
Skellam
sl
@@ -381,7 +343,6 @@ svgnames
sw
symlink
symlinks
synchronised
sys
templated
templating
@@ -391,7 +352,6 @@ th
tibble
tibbles
tidyverse
tidy’
tierney
toc
todo
@@ -400,7 +360,6 @@ toml
toolchain
tooltip
traceback
travis
triaged
trs
tsv
@@ -415,10 +374,7 @@ uk
un
unk
unparsed
user
usethis
usethis's
ushey's
utf
valgrind
vctrs
@@ -432,14 +388,12 @@ vignetteindexentry
virt
vk
Wallenius
warnings
weibo
Weibull
whitelisted
whoami
wickham
withr
word
xaringan
xcode
xcolor
@@ -239,8 +239,12 @@ private void injectContextMenuHandler()
}
word = docDisplay_.getTextForRange(wordRange);

if (word == null || typoSpellChecker_.checkSpelling(word))
if (word == null ||
!typoSpellChecker_.shouldCheckSpelling(docDisplay_, wordRange) ||
typoSpellChecker_.checkSpelling(word))
{
return;
}

// final variables for lambdas
final String replaceWord = word;

0 comments on commit 97af003

Please sign in to comment.
You can’t perform that action at this time.