mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Refactored code to make "WhiteSpace" into "Whitespace"
This commit is contained in:
parent
73c6419c66
commit
85d4895587
|
@ -144,27 +144,23 @@ const isDir = (p: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function pathToReplaceRange(valueBeforeCursor: string, fullValue: string, fullValueRange: Range) {
|
function pathToReplaceRange(valueBeforeCursor: string, fullValue: string, fullValueRange: Range) {
|
||||||
let replaceRange: Range;
|
|
||||||
const lastIndexOfSlash = valueBeforeCursor.lastIndexOf('/');
|
const lastIndexOfSlash = valueBeforeCursor.lastIndexOf('/');
|
||||||
if (lastIndexOfSlash === -1) {
|
if (lastIndexOfSlash === -1) {
|
||||||
replaceRange = fullValueRange;
|
return fullValueRange;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// For cases where cursor is in the middle of attribute value, like <script src="./s|rc/test.js">
|
// For cases where cursor is in the middle of attribute value, like <script src="./s|rc/test.js">
|
||||||
// Find the last slash before cursor, and calculate the start of replace range from there
|
// Find the last slash before cursor, and calculate the start of replace range from there
|
||||||
const valueAfterLastSlash = fullValue.slice(lastIndexOfSlash + 1);
|
const valueAfterLastSlash = fullValue.slice(lastIndexOfSlash + 1);
|
||||||
const startPos = shiftPosition(fullValueRange.end, -valueAfterLastSlash.length);
|
const startPos = shiftPosition(fullValueRange.end, -valueAfterLastSlash.length);
|
||||||
// If whitespace exists, replace until it
|
// If whitespace exists, replace until it
|
||||||
const whiteSpaceIndex = valueAfterLastSlash.indexOf(' ');
|
const whitespaceIndex = valueAfterLastSlash.indexOf(' ');
|
||||||
let endPos;
|
if (whitespaceIndex === -1) {
|
||||||
if (whiteSpaceIndex !== -1) {
|
return Range.create(startPos, shiftPosition(startPos, whitespaceIndex));
|
||||||
endPos = shiftPosition(startPos, whiteSpaceIndex);
|
|
||||||
} else {
|
|
||||||
endPos = fullValueRange.end;
|
|
||||||
}
|
|
||||||
replaceRange = Range.create(startPos, endPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return replaceRange;
|
return Range.create(startPos, fullValueRange.end);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pathToSuggestion(p: string, replaceRange: Range): CompletionItem {
|
function pathToSuggestion(p: string, replaceRange: Range): CompletionItem {
|
||||||
|
@ -180,13 +176,14 @@ function pathToSuggestion(p: string, replaceRange: Range): CompletionItem {
|
||||||
command: 'editor.action.triggerSuggest'
|
command: 'editor.action.triggerSuggest'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label: escapePath(p),
|
label: escapePath(p),
|
||||||
kind: CompletionItemKind.File,
|
kind: CompletionItemKind.File,
|
||||||
textEdit: TextEdit.replace(replaceRange, escapePath(p))
|
textEdit: TextEdit.replace(replaceRange, escapePath(p))
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escape https://www.w3.org/TR/CSS1/#url
|
// Escape https://www.w3.org/TR/CSS1/#url
|
||||||
|
|
|
@ -109,14 +109,13 @@ function pathToSuggestion(p: string, valueBeforeCursor: string, fullValue: strin
|
||||||
const valueAfterLastSlash = fullValue.slice(lastIndexOfSlash + 1);
|
const valueAfterLastSlash = fullValue.slice(lastIndexOfSlash + 1);
|
||||||
const startPos = shiftPosition(range.end, -1 - valueAfterLastSlash.length);
|
const startPos = shiftPosition(range.end, -1 - valueAfterLastSlash.length);
|
||||||
// If whitespace exists, replace until it
|
// If whitespace exists, replace until it
|
||||||
const whiteSpaceIndex = valueAfterLastSlash.indexOf(' ');
|
const whitespaceIndex = valueAfterLastSlash.indexOf(' ');
|
||||||
let endPos;
|
if (whitespaceIndex === -1) {
|
||||||
if (whiteSpaceIndex !== -1) {
|
replaceRange = Range.create(startPos, shiftPosition(range.end, -1));
|
||||||
endPos = shiftPosition(startPos, whiteSpaceIndex);
|
|
||||||
} else {
|
} else {
|
||||||
endPos = shiftPosition(range.end, -1);
|
replaceRange = Range.create(startPos, shiftPosition(startPos, whitespaceIndex));
|
||||||
}
|
}
|
||||||
replaceRange = Range.create(startPos, endPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
|
|
|
@ -904,7 +904,7 @@ const editorConfiguration: IConfigurationNode = {
|
||||||
'enum': ['none', 'boundary', 'selection', 'all'],
|
'enum': ['none', 'boundary', 'selection', 'all'],
|
||||||
'enumDescriptions': [
|
'enumDescriptions': [
|
||||||
'',
|
'',
|
||||||
nls.localize('renderWhiteSpace.boundary', "Render whitespace characters except for single spaces between words."),
|
nls.localize('renderWhitespace.boundary', "Render whitespace characters except for single spaces between words."),
|
||||||
nls.localize('renderWhitespace.selection', "Render whitespace characters only on selected text."),
|
nls.localize('renderWhitespace.selection', "Render whitespace characters only on selected text."),
|
||||||
''
|
''
|
||||||
],
|
],
|
||||||
|
|
|
@ -480,7 +480,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||||
|
|
||||||
this._editor.applyFontInfo(markerElement);
|
this._editor.applyFontInfo(markerElement);
|
||||||
const messageElement = dom.append(markerElement, $('span'));
|
const messageElement = dom.append(markerElement, $('span'));
|
||||||
messageElement.style.whiteSpace = 'pre-wrap';
|
messageElement.style.whitespace = 'pre-wrap';
|
||||||
messageElement.innerText = message;
|
messageElement.innerText = message;
|
||||||
|
|
||||||
if (source || code) {
|
if (source || code) {
|
||||||
|
|
Loading…
Reference in a new issue