Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions src/components/CodeiumEditor/CodeiumEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { LanguageServerService } from '../../api/proto/exa/language_server_pb/la
import { InlineCompletionProvider } from './InlineCompletionProvider';
import { CodeiumLogo } from '../CodeiumLogo/CodeiumLogo';
import { Document } from '../../models';
import { deepMerge } from '../../utils/merge';

export interface CodeiumEditorProps extends EditorProps {
language: string;
Expand Down Expand Up @@ -184,26 +185,28 @@ export const CodeiumEditor: React.FC<CodeiumEditorProps> = ({
width={layout.width}
height={layout.height}
onMount={handleEditorDidMount}
options={{
scrollBeyondLastColumn: 0,
scrollbar: {
alwaysConsumeMouseWheel: false,
options={deepMerge<editor.IStandaloneEditorConstructionOptions>(
props.options,
{
scrollBeyondLastColumn: 0,
scrollbar: {
alwaysConsumeMouseWheel: false,
},
codeLens: false,
// for resizing, but apparently might have "severe performance impact"
// automaticLayout: true,
minimap: {
enabled: false,
},
quickSuggestions: false,
folding: false,
foldingHighlight: false,
foldingImportsByDefault: false,
links: false,
fontSize: 14,
wordWrap: 'on',
},
codeLens: false,
// for resizing, but apparently might have "severe performance impact"
// automaticLayout: true,
minimap: {
enabled: false,
},
quickSuggestions: false,
folding: false,
foldingHighlight: false,
foldingImportsByDefault: false,
links: false,
fontSize: 14,
wordWrap: 'on',
...props.options,
}}
)}
/>
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions src/stories/CodeiumEditor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ export const MultiFileContext: Story = {
args: {
...baseParams,
language: 'javascript',
options: {
scrollbar: {
vertical: 'hidden',
},
},
value: `// You have context over a sample HTML page.
// Codeium's generation will take this context into account when suggesting.

Expand Down
31 changes: 31 additions & 0 deletions src/utils/merge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Merges a partial object with a fallback object, deeply combining the two.
*
* @param {Partial<T>} partial - the partial object to merge (can be undefined)
* @param {T} fallback - the fallback object to merge with
* @return {T} the merged object
*/
export function deepMerge<T>(partial: Partial<T> | undefined, fallback: T): T {
const merged: any = { ...fallback };

for (const key in partial) {
if (typeof partial[key] === 'object' && !Array.isArray(partial[key])) {
if (
fallback[key] &&
typeof fallback[key] === 'object' &&
!Array.isArray(fallback[key])
) {
merged[key] = deepMerge(
partial[key] as Partial<T> | undefined,
fallback[key] as T,
);
} else {
merged[key] = { ...partial[key] };
}
} else {
merged[key] = partial[key];
}
}

return merged;
}