mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-09 10:28:32 +00:00
Fixed missing translations
Aligned the languge pack versions. Closes #1431 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import {
|
||||
SearchInWorkspaceFileNode,
|
||||
SearchInWorkspaceResultTreeWidget as TheiaSearchInWorkspaceResultTreeWidget,
|
||||
} from '@theia/search-in-workspace/lib/browser/search-in-workspace-result-tree-widget';
|
||||
import { MEMORY_TEXT } from '@theia/core/lib/common/resource';
|
||||
|
||||
/**
|
||||
* Workaround for https://github.com/eclipse-theia/theia/pull/9192/.
|
||||
*/
|
||||
@injectable()
|
||||
export class SearchInWorkspaceResultTreeWidget extends TheiaSearchInWorkspaceResultTreeWidget {
|
||||
protected override async createReplacePreview(
|
||||
node: SearchInWorkspaceFileNode
|
||||
): Promise<URI> {
|
||||
const fileUri = new URI(node.fileUri).withScheme('file');
|
||||
const openedEditor = this.editorManager.all.find(
|
||||
({ editor }) => editor.uri.toString() === fileUri.toString()
|
||||
);
|
||||
let content: string;
|
||||
if (openedEditor) {
|
||||
content = openedEditor.editor.document.getText();
|
||||
} else {
|
||||
const resource = await this.fileResourceResolver.resolve(fileUri);
|
||||
content = await resource.readContents();
|
||||
}
|
||||
|
||||
const lines = content.split('\n');
|
||||
node.children.map((l) => {
|
||||
const leftPositionedNodes = node.children.filter(
|
||||
(rl) => rl.line === l.line && rl.character < l.character
|
||||
);
|
||||
const diff =
|
||||
(this._replaceTerm.length - this.searchTerm.length) *
|
||||
leftPositionedNodes.length;
|
||||
const start = lines[l.line - 1].substr(0, l.character - 1 + diff);
|
||||
const end = lines[l.line - 1].substr(l.character - 1 + diff + l.length);
|
||||
lines[l.line - 1] = start + this._replaceTerm + end;
|
||||
});
|
||||
|
||||
return fileUri.withScheme(MEMORY_TEXT).withQuery(lines.join('\n'));
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
import { injectable, postConstruct } from '@theia/core/shared/inversify';
|
||||
import * as React from '@theia/core/shared/react';
|
||||
import { Key, KeyCode } from '@theia/core/lib/browser';
|
||||
import { SearchInWorkspaceWidget as TheiaSearchInWorkspaceWidget } from '@theia/search-in-workspace/lib/browser/search-in-workspace-widget';
|
||||
|
||||
/**
|
||||
* Workaround for https://github.com/eclipse-theia/theia/pull/9183.
|
||||
*/
|
||||
@injectable()
|
||||
export class SearchInWorkspaceWidget extends TheiaSearchInWorkspaceWidget {
|
||||
@postConstruct()
|
||||
protected override init(): void {
|
||||
super.init();
|
||||
this.title.iconClass = 'fa fa-arduino-search';
|
||||
}
|
||||
|
||||
protected override renderGlobField(kind: 'include' | 'exclude'): React.ReactNode {
|
||||
const currentValue = this.searchInWorkspaceOptions[kind];
|
||||
const value = (currentValue && currentValue.join(', ')) || '';
|
||||
return (
|
||||
<div className="glob-field">
|
||||
<div className="label">{'files to ' + kind}</div>
|
||||
<input
|
||||
className="theia-input"
|
||||
type="text"
|
||||
size={1}
|
||||
defaultValue={value}
|
||||
id={kind + '-glob-field'}
|
||||
onKeyUp={(e) => {
|
||||
if (e.target) {
|
||||
const targetValue = (e.target as HTMLInputElement).value || '';
|
||||
let shouldSearch =
|
||||
Key.ENTER.keyCode ===
|
||||
KeyCode.createKeyCode(e.nativeEvent).key?.keyCode;
|
||||
const currentOptions = (this.searchInWorkspaceOptions[kind] || [])
|
||||
.slice()
|
||||
.map((s) => s.trim())
|
||||
.sort();
|
||||
const candidateOptions = this.splitOnComma(targetValue)
|
||||
.map((s) => s.trim())
|
||||
.sort();
|
||||
const sameAs = (left: string[], right: string[]) => {
|
||||
if (left.length !== right.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < left.length; i++) {
|
||||
if (left[i] !== right[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (!sameAs(currentOptions, candidateOptions)) {
|
||||
this.searchInWorkspaceOptions[kind] =
|
||||
this.splitOnComma(targetValue);
|
||||
shouldSearch = true;
|
||||
}
|
||||
if (shouldSearch) {
|
||||
this.resultTreeWidget.search(
|
||||
this.searchTerm,
|
||||
this.searchInWorkspaceOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
}}
|
||||
onFocus={
|
||||
kind === 'include'
|
||||
? this.handleFocusIncludesInputBox
|
||||
: this.handleFocusExcludesInputBox
|
||||
}
|
||||
onBlur={
|
||||
kind === 'include'
|
||||
? this.handleBlurIncludesInputBox
|
||||
: this.handleBlurExcludesInputBox
|
||||
}
|
||||
></input>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user