mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 06:55:26 +02:00
fix(server): Improve namin
This commit is contained in:
parent
a2decaeff3
commit
ac97ec77ef
@ -50,13 +50,13 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
|
||||
}
|
||||
}
|
||||
|
||||
fileRequired := (v.RequiredType & PathTypeFile) == PathTypeFile
|
||||
directoryRequired := (v.RequiredType & PathTypeDirectory) == PathTypeDirectory
|
||||
fileExpected := (v.RequiredType & PathTypeFile) == PathTypeFile
|
||||
directoryExpected := (v.RequiredType & PathTypeDirectory) == PathTypeDirectory
|
||||
|
||||
isValid := true
|
||||
|
||||
// If file is expected
|
||||
if fileRequired {
|
||||
if fileExpected {
|
||||
// and exists
|
||||
isValid = isValid && utils.IsPathFile(value)
|
||||
// file not expected
|
||||
@ -66,7 +66,7 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
|
||||
}
|
||||
|
||||
// if directory
|
||||
if directoryRequired {
|
||||
if directoryExpected {
|
||||
// and exists
|
||||
isValid = isValid && utils.IsPathDirectory(value)
|
||||
// directory not expected
|
||||
@ -79,21 +79,21 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
|
||||
return nil
|
||||
}
|
||||
|
||||
if fileRequired && directoryRequired {
|
||||
if fileExpected && directoryExpected {
|
||||
return []*InvalidValue{{
|
||||
Err: errors.New("This must be either a file or a directory"),
|
||||
Start: 0,
|
||||
End: uint32(len(value)),
|
||||
}}
|
||||
}
|
||||
if fileRequired {
|
||||
if fileExpected {
|
||||
return []*InvalidValue{{
|
||||
Err: errors.New("This must be a file"),
|
||||
Start: 0,
|
||||
End: uint32(len(value)),
|
||||
}}
|
||||
}
|
||||
if directoryRequired {
|
||||
if directoryExpected {
|
||||
return []*InvalidValue{{
|
||||
Err: errors.New("This must be a directory"),
|
||||
Start: 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user